B
- The Http message bodypublic interface PushCapableHttpRequest<B> extends HttpRequest<B>
HttpRequest
that is potentially capable of HTTP2 server push. Code should check
isServerPushSupported()
before attempting to send any server push.SCHEME_HTTP, SCHEME_HTTPS
Modifier and Type | Method and Description |
---|---|
boolean |
isServerPushSupported()
Check whether HTTP2 server push is supported by the remote client.
|
PushCapableHttpRequest<B> |
serverPush(HttpRequest<?> request)
Initiate a HTTP2 server push for the given request.
|
accept, create, create, DELETE, DELETE, DELETE, GET, GET, getCertificate, getCookies, getHttpVersion, getLocale, getMethod, getMethodName, getParameters, getPath, getRemoteAddress, getServerAddress, getServerName, getUri, getUserPrincipal, getUserPrincipal, HEAD, HEAD, isSecure, mutate, OPTIONS, OPTIONS, PATCH, PATCH, POST, POST, PUT, PUT, setAttribute
getAttributes, getBody, getBody, getBody, getCharacterEncoding, getContentLength, getContentType, getHeaders
removeAttribute
getAttribute, getAttribute
boolean isServerPushSupported()
true
.true
iff server push is supported.PushCapableHttpRequest<B> serverPush(@NonNull HttpRequest<?> request)
Initiate a HTTP2 server push for the given request. The information from the given request (i.e. path, headers) will be passed on to the client immediately so that it does not send the request itself. Then, the given request will be handled as if it was initiated by the client, and the response will be passed back to the client.
This method mostly follows the semantics of JavaEE javax.servlet.http.PushBuilder
. This means most of
the headers of this request are copied into the push request, and the referer is set. To override this
behavior, add a corresponding header to the request
passed as the parameter of this method: those
headers take precedence.
Security note: The Authorization
header and other headers not excluded by the above paragraph
will be copied and sent to the client as part of a HTTP2 PUSH_PROMISE
. Normally, this is fine, because
the client sent those headers in the first place. But if there is an intermediate proxy that added a header,
this header may then leak to the client.
request
- The request to respond to using a server push.UnsupportedOperationException
- if the client does not support server push. Check beforehand using
isServerPushSupported()
.