Class CombineRequest
java.lang.Object
org.frontcache.include.combine.CombineRequest
The origin's half of the combine contract: read a combined request.
This is not used by the edge. It exists so a JVM origin implements the contract by calling the
same code that defines it, rather than by re-reading section 5 of the proposal and getting the
parameter names nearly right. A non-JVM origin implements about thirty lines - decode n values,
batch, emit JSON.
Typical handler:
List<Map<String, String[]>> parts = CombineRequest.parseParameters(request);
if (null == parts)
return renderSingle(request); // ordinary single-fragment request
// ONE batched query over every part's keys - this is the entire point of the feature
Map<Long, Coin> coins = dao.getByIds(idsOf(parts));
CombineResponse out = new CombineResponse();
for (Map<String, String[]> part : parts)
out.add(CombineRequest.queryOf(part), render(coins, part), headersFor(part));
out.writeTo(response);
-
Method Summary
Modifier and TypeMethodDescriptionUnmodifiable empty member, for a handler that wants a non-null default.static booleanisCombined(jakarta.servlet.http.HttpServletRequest request) Is this a combined request? Cheap enough to call at the top of a handler.static StringFirst value of a parameter within one parsed member, or null.parseParameters(jakarta.servlet.http.HttpServletRequest request) The members' parameters, parsed, in order.parseQueries(jakarta.servlet.http.HttpServletRequest request) The members' query strings, decoded, in order.parseQueryString(String query) Splits one member's query string into parameters.static StringRe-renders a parsed member back into a query string, for the optionalqecho (CombinePart.getQ()).static intversion(jakarta.servlet.http.HttpServletRequest request) The protocol version the edge is speaking, or -1 when this is not a combined request.
-
Method Details
-
isCombined
public static boolean isCombined(jakarta.servlet.http.HttpServletRequest request) Is this a combined request? Cheap enough to call at the top of a handler. -
version
public static int version(jakarta.servlet.http.HttpServletRequest request) The protocol version the edge is speaking, or -1 when this is not a combined request. An origin that only implements version 1 should answer a higher version as it would answer an ordinary single request - the edge then degrades correctly (proposal section 9.1) instead of receiving an envelope it cannot read. -
parseQueries
The members' query strings, decoded, in order.nullwhen this is not a combined request, so a handler can branch on it directly. A missingfc-part-iis returned as an empty string rather than dropped: the response is positional, so silently shortening the list would misalign every later member. -
parseParameters
public static List<Map<String,String[]>> parseParameters(jakarta.servlet.http.HttpServletRequest request) The members' parameters, parsed, in order.nullwhen this is not a combined request. The maps preserve parameter order and support repeated parameters, so a member query behaves the wayrequest.getParameterMap()would have behaved for a single include. -
parseQueryString
Splits one member's query string into parameters. Values are percent-decoded with UTF-8. Written out rather than delegated to the container because the member query arrived as a value: by the time it is in hand there is no request to ask. -
param
-
queryOf
Re-renders a parsed member back into a query string, for the optionalqecho (CombinePart.getQ()). Handlers that keptparseQueries(HttpServletRequest)' strings should echo those instead - this is for handlers that only kept the parsed form. -
emptyPart
-