T - The type@Internal public class NettyHttpRequest<T> extends AbstractNettyHttpRequest<T> implements HttpRequest<T>, PushCapableHttpRequest<T>
HttpRequest instance.conversionService, HTTP2_SCHEME, httpMethod, httpMethodName, nettyRequest, STREAM_ID, uriSCHEME_HTTP, SCHEME_HTTPS| Constructor and Description |
|---|
NettyHttpRequest(io.netty.handler.codec.http.HttpRequest nettyRequest,
io.netty.channel.ChannelHandlerContext ctx,
ConversionService environment,
HttpServerConfiguration serverConfiguration) |
| Modifier and Type | Method and Description |
|---|---|
void |
addContent(io.netty.buffer.ByteBufHolder httpContent) |
protected Object |
buildBody() |
Optional<Object> |
getAttribute(CharSequence name)
Obtain the value of an attribute on the HTTP method.
|
MutableConvertibleValues<Object> |
getAttributes()
A
MutableConvertibleValues of the attributes for this HTTP message. |
Optional<T> |
getBody() |
<T1> Optional<T1> |
getBody(Argument<T1> type)
Return the body as the given type.
|
<T1> Optional<T1> |
getBody(Class<T1> type)
Return the body as the given type.
|
io.netty.channel.ChannelHandlerContext |
getChannelHandlerContext() |
Cookies |
getCookies() |
HttpHeaders |
getHeaders() |
RouteMatch<?> |
getMatchedRoute() |
io.netty.handler.codec.http.HttpRequest |
getNativeRequest() |
InetSocketAddress |
getRemoteAddress() |
InetSocketAddress |
getServerAddress() |
String |
getServerName() |
protected Charset |
initCharset(Charset characterEncoding) |
boolean |
isSecure() |
boolean |
isServerPushSupported()
Check whether HTTP2 server push is supported by the remote client.
|
MutableHttpRequest<T> |
mutate()
Returns a new request object that allows mutation.
|
void |
prepareHttp2ResponseIfNecessary(io.netty.handler.codec.http.HttpResponse finalResponse)
Prepares a response based on this HTTP/2 request if HTTP/2 is enabled.
|
void |
release()
Release and cleanup resources.
|
protected void |
releaseIfNecessary(Object value) |
PushCapableHttpRequest<T> |
serverPush(@NotNull HttpRequest<?> request)
Initiate a HTTP2 server push for the given request.
|
void |
setBody(T body)
Sets the body.
|
String |
toString() |
accept, createDecoder, getCharacterEncoding, getContentType, getHttpVersion, getLocale, getMethod, getMethodName, getNettyRequest, getParameters, getPath, getUri, isStream, toFullHttpRequest, toHttpRequest, toStreamHttpRequestclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaccept, create, create, DELETE, DELETE, DELETE, GET, GET, getCertificate, getHttpVersion, getLocale, getMethod, getMethodName, getParameters, getPath, getUri, getUserPrincipal, getUserPrincipal, HEAD, HEAD, OPTIONS, OPTIONS, PATCH, PATCH, POST, POST, PUT, PUT, setAttributegetCharacterEncoding, getContentLength, getContentTyperemoveAttributegetAttributetoHttpRequestpublic NettyHttpRequest(io.netty.handler.codec.http.HttpRequest nettyRequest,
io.netty.channel.ChannelHandlerContext ctx,
ConversionService environment,
HttpServerConfiguration serverConfiguration)
nettyRequest - The HttpRequestctx - The ChannelHandlerContextenvironment - The EnvironmentserverConfiguration - The HttpServerConfiguration@Internal public final void prepareHttp2ResponseIfNecessary(@NonNull io.netty.handler.codec.http.HttpResponse finalResponse)
finalResponse - The response to prepare, never nullpublic MutableHttpRequest<T> mutate()
HttpRequestmutate in interface HttpRequest<T>@NonNull public Optional<Object> getAttribute(CharSequence name)
AttributeHoldergetAttribute in interface AttributeHoldername - The name of the attributeOptional valuepublic io.netty.handler.codec.http.HttpRequest getNativeRequest()
public io.netty.channel.ChannelHandlerContext getChannelHandlerContext()
ChannelHandlerContextpublic Cookies getCookies()
getCookies in interface HttpRequest<T>Cookies instancepublic InetSocketAddress getRemoteAddress()
getRemoteAddress in interface HttpRequest<T>public InetSocketAddress getServerAddress()
getServerAddress in interface HttpRequest<T>public String getServerName()
getServerName in interface HttpRequest<T>public boolean isSecure()
isSecure in interface HttpRequest<T>public HttpHeaders getHeaders()
getHeaders in interface HttpMessage<T>HttpHeaders objectpublic MutableConvertibleValues<Object> getAttributes()
HttpMessageA MutableConvertibleValues of the attributes for this HTTP message.
Attributes are designed for internal data sharing and hence are isolated from headers and parameters which are client supplied
getAttributes in interface AttributeHoldergetAttributes in interface MutableAttributeHoldergetAttributes in interface HttpMessage<T>public Optional<T> getBody()
getBody in interface HttpMessage<T>protected Object buildBody()
CompositeByteBufpublic <T1> Optional<T1> getBody(Class<T1> type)
HttpMessagegetBody in interface HttpMessage<T>T1 - The generic typetype - The type of the bodyOptional of the type or Optional.empty() if the body cannot be returned as the given typepublic <T1> Optional<T1> getBody(Argument<T1> type)
HttpMessagegetBody in interface HttpMessage<T>T1 - The generic typetype - The type of the bodyOptional of the type or Optional.empty() if the body cannot be returned as the given type@Internal public void release()
protected void releaseIfNecessary(Object value)
value - An object with a value@Internal public RouteMatch<?> getMatchedRoute()
@Internal public void addContent(io.netty.buffer.ByteBufHolder httpContent)
httpContent - The HttpContent as ByteBufHolderpublic boolean isServerPushSupported()
PushCapableHttpRequesttrue.isServerPushSupported in interface PushCapableHttpRequest<T>true iff server push is supported.public PushCapableHttpRequest<T> serverPush(@NotNull @NotNull HttpRequest<?> request)
PushCapableHttpRequestInitiate 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.
serverPush in interface PushCapableHttpRequest<T>request - The request to respond to using a server push.protected Charset initCharset(Charset characterEncoding)
initCharset in class AbstractNettyHttpRequest<T>characterEncoding - The charactger encoding