Class CombineProtocol
java.lang.Object
org.frontcache.include.combine.CombineProtocol
The combine-and-reduce wire contract, in one place: parameter names, the encoding of a member's
query string, and the small URL arithmetic both ends need.
See docs/archive/combine-reduce-proposal.md sections 5 and 6. Both halves of the contract live in this
package so an origin embedding frontcache-core cannot drift from the edge - see
CombineRequest and CombineResponse, which are the origin's half.
Request
GET {path}?fc-combine=1&fc-parts={n}&fc-part-0={q0}&fc-part-1={q1}&...
where q(i) is member i's complete original query string (no leading ?), percent-encoded
as a single value.
Why the parts are indexed rather than repeated
fc-part=a&fc-part=b would be shorter, and would make the origin depend on its container
preserving the order of getParameterValues - which the servlet spec does not require.
The response is positional against i, so an ordering the origin cannot rely on is exactly the
wrong thing to build the contract from. With fc-part-{i} the origin reads a known index
and the question does not arise.
Why a member's query is carried as one encoded value
Because it is injection-safe by construction: a member's query is a value, never concatenated into the query grammar, so no include URL can smuggle a parameter into the combined request or into a sibling member. It is also the only shape that survives members differing in more than one parameter, or in which parameters they carry at all - see the proposal section 5.1 for why?id=1|2|3 was not taken.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StringResponse header.static final StringPresence makes a request a combined request; the value isVERSION.static final StringPrefix of the per-member parameter:fc-part-0,fc-part-1, ...static final StringNumber of members.static final StringReserved query-parameter prefix.static final intProtocol version. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildCombinedQuery(List<String> memberQueries) The combined query string, including the leading?.static StringdecodePart(String encoded) Inverse ofencodePart(String).static StringencodePart(String query) Percent-encodes one member query string for transport as a single parameter value.static StringendpointOf(String url) Everything before the?- the endpoint a batch is grouped by and addressed to.static StringBatch identity: the endpoint plus thecombineattribute's value.static booleanhasReservedParam(String query) Does this query string carry a parameter whose name is inside the reservedfc-space? Such an include is not combinable: its parameter would arrive at the origin beside the ones this protocol puts there, and the origin has no way to tell them apart.static StringThe URI path of an absolute include URL -http://host:8080/a/b.htm?x=1to/a/b.htm.static StringEverything after the?, or""when there is none.
-
Field Details
-
VERSION
public static final int VERSIONProtocol version. Sent as the value ofPARAM_COMBINEand echoed inHEADER_COMBINE.- See Also:
-
PARAM_PREFIX
Reserved query-parameter prefix. An include whose own query carries a parameter starting with this is never combined - the edge refuses rather than risk a collision the origin cannot detect.- See Also:
-
PARAM_COMBINE
-
PARAM_PARTS
Number of members. Lets the origin size its batch before parsing, and the edge check the answer.- See Also:
-
PARAM_PART
Prefix of the per-member parameter:fc-part-0,fc-part-1, ...- See Also:
-
HEADER_COMBINE
Response header. Its presence on a 2xx is the ONLY signal that the origin understood the request - an origin that does not implement combining answers something else, and the edge degrades (proposal section 9.1). A header rather than a media type becausex-frontcache-*names are already chosen to survive every intermediary in the deployment (see FCHeaders).- See Also:
-
ENVELOPE_CONTENT_TYPE
- See Also:
-
-
Method Details
-
buildCombinedQuery
-
encodePart
Percent-encodes one member query string for transport as a single parameter value.application/x-www-form-urlencoded(space as+), which is what every servlet container decodes query parameters as - so the origin's owngetParameterhands the member's query back already decoded. -
decodePart
Inverse ofencodePart(String). -
hasReservedParam
Does this query string carry a parameter whose name is inside the reservedfc-space? Such an include is not combinable: its parameter would arrive at the origin beside the ones this protocol puts there, and the origin has no way to tell them apart. -
endpointOf
-
pathOf
The URI path of an absolute include URL -http://host:8080/a/b.htm?x=1to/a/b.htm. Exists so the combine path can applydynamic-urls.confto a member the wayFrontCacheEngine.ignoreCacheapplies it to a request: against the path, since that is whatRequestContext.getRequestURI()holds. Matching a different string here would make a combined member cacheable where a single include was not. -
queryOf
-
groupKey
-