Interface PushCapableHttpRequest<B>
-
- Type Parameters:
B
- The Http message body
- All Superinterfaces:
io.micronaut.core.attr.AttributeHolder
,HttpMessage<B>
,HttpRequest<B>
,io.micronaut.core.attr.MutableAttributeHolder
public interface PushCapableHttpRequest<B> extends HttpRequest<B>
AHttpRequest
that is potentially capable of HTTP2 server push. Code should checkisServerPushSupported()
before attempting to send any server push.- Since:
- 3.2
-
-
Field Summary
-
Fields inherited from interface io.micronaut.http.HttpRequest
SCHEME_HTTP, SCHEME_HTTPS
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method 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.-
Methods inherited from interface io.micronaut.http.HttpMessage
getAttributes, getBody, getBody, getBody, getCharacterEncoding, getContentLength, getContentType, getHeaders
-
Methods inherited from interface io.micronaut.http.HttpRequest
accept, getCertificate, getCookies, getHttpVersion, getLocale, getMethod, getMethodName, getParameters, getPath, getRemoteAddress, getServerAddress, getServerName, getUri, getUserPrincipal, getUserPrincipal, isSecure, mutate, setAttribute
-
-
-
-
Method Detail
-
isServerPushSupported
boolean isServerPushSupported()
Check whether HTTP2 server push is supported by the remote client. Only HTTP2 clients that indicate support through HTTP2 settings have this method returntrue
.- Returns:
true
iff server push is supported.
-
serverPush
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 therequest
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 HTTP2PUSH_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.- Parameters:
request
- The request to respond to using a server push.- Returns:
- This request.
- Throws:
java.lang.UnsupportedOperationException
- if the client does not support server push. Check beforehand usingisServerPushSupported()
.
-
-