@UnstableApi public abstract class NonWrappingRequestContext extends Object implements RequestContext
RequestContext implementation that helps to implement a non-wrapping
RequestContext.| Modifier | Constructor and Description |
|---|---|
protected |
NonWrappingRequestContext(MeterRegistry meterRegistry,
SessionProtocol sessionProtocol,
RequestId id,
HttpMethod method,
String path,
String query,
HttpRequest req,
RpcRequest rpcReq,
RequestContext rootAttributeMap)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
<V> V |
attr(io.netty.util.AttributeKey<V> key)
Returns the value mapped to the given
AttributeKey or null if there's no value set by
RequestContext.setAttr(AttributeKey, Object) or RequestContext.setAttrIfAbsent(AttributeKey, Object). |
Iterator<Map.Entry<io.netty.util.AttributeKey<?>,Object>> |
attrs()
|
protected abstract io.netty.channel.Channel |
channel()
Returns the
Channel that is handling this request, or null if the connection is not
established yet. |
<V> V |
computeAttrIfAbsent(io.netty.util.AttributeKey<V> key,
Function<? super io.netty.util.AttributeKey<V>,? extends V> mappingFunction)
If the specified
AttributeKey is not already associated with a value (or is mapped
to null), attempts to compute its value using the given mapping
function and stores it into this context. |
String |
decodedPath()
Returns the absolute path part of the current
Request URI, excluding the query part,
decoded in UTF-8. |
RequestId |
id()
|
<A extends SocketAddress> |
localAddress()
Returns the local address of this request, or
null if the connection is not established yet. |
MeterRegistry |
meterRegistry()
Returns the
MeterRegistry that collects various stats. |
HttpMethod |
method()
Returns the HTTP method of the current
Request. |
<V> V |
ownAttr(io.netty.util.AttributeKey<V> key)
Returns the value mapped to the given
AttributeKey or null if there's no value set by
setAttr(AttributeKey, Object) or setAttrIfAbsent(AttributeKey, Object). |
Iterator<Map.Entry<io.netty.util.AttributeKey<?>,Object>> |
ownAttrs()
|
String |
path()
|
String |
query()
Returns the query part of the current
Request URI, without the leading '?' |
<A extends SocketAddress> |
remoteAddress()
Returns the remote address of this request, or
null if the connection is not established yet. |
HttpRequest |
request()
Returns the
HttpRequest associated with this context, or null if there's no
HttpRequest associated with this context yet. |
RpcRequest |
rpcRequest()
Returns the
RpcRequest associated with this context, or null if there's no
RpcRequest associated with this context. |
SessionProtocol |
sessionProtocol()
Returns the
SessionProtocol of the current Request. |
<V> void |
setAttr(io.netty.util.AttributeKey<V> key,
V value)
Associates the specified value with the given
AttributeKey in this context. |
<V> V |
setAttrIfAbsent(io.netty.util.AttributeKey<V> key,
V value)
Associates the specified value with the given
AttributeKey in this context only
if this context does not contain a mapping for the AttributeKey. |
protected void |
unsafeUpdateRequest(HttpRequest req)
Replaces the
HttpRequest associated with this context with the specified one
without any validation. |
void |
updateRequest(HttpRequest req)
Replaces the
HttpRequest associated with this context with the specified one. |
void |
updateRpcRequest(RpcRequest rpcReq)
Replaces the
RpcRequest associated with this context with the specified one. |
protected void |
validateHeaders(RequestHeaders headers)
Validates the specified
RequestHeaders. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitalloc, contextAwareEventLoop, contextAwareExecutor, current, currentOrNull, eventLoop, executor, log, logBuilder, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, mapCurrent, newDerivedContext, push, push, push, push, pushIfAbsent, rejectPromise, replace, resolvePromise, sslSessionprotected NonWrappingRequestContext(MeterRegistry meterRegistry, SessionProtocol sessionProtocol, RequestId id, HttpMethod method, String path, String query, HttpRequest req, RpcRequest rpcReq, RequestContext rootAttributeMap)
sessionProtocol - the SessionProtocol of the invocationid - the RequestId associated with this contextreq - the HttpRequest associated with this contextrpcReq - the RpcRequest associated with this contextpublic HttpRequest request()
RequestContextHttpRequest associated with this context, or null if there's no
HttpRequest associated with this context yet.request in interface RequestContextpublic RpcRequest rpcRequest()
RequestContextRpcRequest associated with this context, or null if there's no
RpcRequest associated with this context.rpcRequest in interface RequestContextpublic final void updateRequest(HttpRequest req)
RequestContextHttpRequest associated with this context with the specified one.
This method is useful to a decorator that manipulates HTTP request headers.
Note that it is a bad idea to change the values of the pseudo headers (":method",
":path", ":scheme" and ":authority") when replacing an HttpRequest,
because the properties of this context, such as RequestContext.path(), are unaffected by such an attempt.
updateRequest in interface RequestContextHttpRequest.withHeaders(RequestHeaders),
HttpRequest.withHeaders(RequestHeadersBuilder)public final void updateRpcRequest(RpcRequest rpcReq)
RequestContextRpcRequest associated with this context with the specified one.
This method is useful to a decorator that manipulates an RPC call.updateRpcRequest in interface RequestContextprotected void validateHeaders(RequestHeaders headers)
RequestHeaders. By default, this method will raise
an IllegalArgumentException if it does not have ":scheme" or ":authority"
header.protected final void unsafeUpdateRequest(HttpRequest req)
HttpRequest associated with this context with the specified one
without any validation. Internal use only. Use it at your own risk.public final SessionProtocol sessionProtocol()
RequestContextSessionProtocol of the current Request.sessionProtocol in interface RequestContextprotected abstract io.netty.channel.Channel channel()
Channel that is handling this request, or null if the connection is not
established yet.public <A extends SocketAddress> A remoteAddress()
RequestContextnull if the connection is not established yet.remoteAddress in interface RequestContextpublic <A extends SocketAddress> A localAddress()
RequestContextnull if the connection is not established yet.localAddress in interface RequestContextpublic final RequestId id()
RequestContextid in interface RequestContextpublic final HttpMethod method()
RequestContextRequest.method in interface RequestContextpublic final String path()
RequestContextRequest URI, excluding the query part,
as defined in RFC3986.path in interface RequestContextpublic final String decodedPath()
RequestContextRequest URI, excluding the query part,
decoded in UTF-8.decodedPath in interface RequestContextpublic final String query()
RequestContextquery in interface RequestContextpublic final MeterRegistry meterRegistry()
RequestContextMeterRegistry that collects various stats.meterRegistry in interface RequestContextpublic <V> V attr(io.netty.util.AttributeKey<V> key)
RequestContextAttributeKey or null if there's no value set by
RequestContext.setAttr(AttributeKey, Object) or RequestContext.setAttrIfAbsent(AttributeKey, Object).attr in interface RequestContextpublic <V> V ownAttr(io.netty.util.AttributeKey<V> key)
AttributeKey or null if there's no value set by
setAttr(AttributeKey, Object) or setAttrIfAbsent(AttributeKey, Object).
Unlike attr(AttributeKey), this does not search in rootAttributeMap.attr(AttributeKey)public <V> void setAttr(io.netty.util.AttributeKey<V> key,
V value)
RequestContextAttributeKey in this context.
If this context previously contained a mapping for the AttributeKey,
the old value is replaced by the specified value. Set null not to iterate the mapping from
RequestContext.attrs().setAttr in interface RequestContextpublic <V> V setAttrIfAbsent(io.netty.util.AttributeKey<V> key,
V value)
RequestContextAttributeKey in this context only
if this context does not contain a mapping for the AttributeKey.setAttrIfAbsent in interface RequestContextnull if there was no mapping for the AttributeKey or the old value if there's
a mapping for the AttributeKey.public <V> V computeAttrIfAbsent(io.netty.util.AttributeKey<V> key,
Function<? super io.netty.util.AttributeKey<V>,? extends V> mappingFunction)
RequestContextAttributeKey is not already associated with a value (or is mapped
to null), attempts to compute its value using the given mapping
function and stores it into this context.
If the mapping function returns null, no mapping is recorded.
computeAttrIfAbsent in interface RequestContextAttributeKey, or null if the computed value is nullpublic Iterator<Map.Entry<io.netty.util.AttributeKey<?>,Object>> attrs()
RequestContextattrs in interface RequestContextCopyright © 2020 LeanCloud. All rights reserved.