public class ClientRequestContextWrapper extends RequestContextWrapper<ClientRequestContext> implements ClientRequestContext
ClientRequestContext.| Modifier | Constructor and Description |
|---|---|
protected |
ClientRequestContextWrapper(ClientRequestContext delegate)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAdditionalRequestHeader(CharSequence name,
Object value)
Adds a header with the specified
name and value. |
void |
addAdditionalRequestHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
|
HttpHeaders |
additionalRequestHeaders()
|
Endpoint |
endpoint()
|
EndpointSelector |
endpointSelector()
Returns the
EndpointSelector used for the current Request. |
String |
fragment()
Returns the fragment part of the URI of the current
Request, as defined in
the section 3.5 of RFC3986. |
long |
maxResponseLength()
Returns the maximum length of the received
Response. |
ClientRequestContext |
newDerivedContext(RequestId id,
HttpRequest req,
RpcRequest rpcReq,
Endpoint endpoint)
Creates a new
ClientRequestContext whose properties and Attributes are copied from this
ClientRequestContext, except having different Request, Endpoint and its own
RequestLog. |
ClientOptions |
options()
Returns the
ClientOptions of the current Request. |
boolean |
removeAdditionalRequestHeader(CharSequence name)
Removes all headers with the specified
name. |
Runnable |
responseTimeoutHandler()
Returns
Response timeout handler which is executed when
the Response is not completely received within the allowed ClientRequestContext.responseTimeoutMillis()
or the default ClientOption.RESPONSE_TIMEOUT_MILLIS. |
long |
responseTimeoutMillis()
|
void |
setAdditionalRequestHeader(CharSequence name,
Object value)
Sets a header with the specified
name and value. |
void |
setAdditionalRequestHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Clears the current header and sets the specified
HttpHeaders which is included when a
Client sends an HttpRequest. |
void |
setMaxResponseLength(long maxResponseLength)
Sets the maximum length of the received
Response. |
void |
setResponseTimeout(Duration responseTimeout)
|
void |
setResponseTimeoutHandler(Runnable responseTimeoutHandler)
Sets a handler to run when the response times out.
|
void |
setResponseTimeoutMillis(long responseTimeoutMillis)
|
void |
setWriteTimeout(Duration writeTimeout)
Returns the amount of time allowed until the initial write attempt of the current
Request
succeeds. |
void |
setWriteTimeoutMillis(long writeTimeoutMillis)
Returns the amount of time allowed until the initial write attempt of the current
Request
succeeds. |
long |
writeTimeoutMillis()
Returns the amount of time allowed until the initial write attempt of the current
Request
succeeds. |
alloc, attr, attrs, decodedPath, delegate, eventLoop, hasAttr, id, invokeOnChildCallbacks, invokeOnEnterCallbacks, invokeOnExitCallbacks, localAddress, log, logBuilder, meterRegistry, method, onChild, onEnter, onExit, path, query, remoteAddress, request, rpcRequest, sessionProtocol, sslSession, updateRequest, updateRpcRequestcontextAwareEventLoop, contextAwareExecutor, equals, executor, hashCode, isTimedOut, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, onEnter, onExit, push, push, pushIfAbsent, rejectPromise, resolvePromise, setTimedOutclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitbuilder, builder, builder, current, currentOrNull, mapCurrent, newDerivedContext, of, of, of, request, rpcRequestalloc, attrs, contextAwareEventLoop, contextAwareExecutor, decodedPath, eventLoop, executor, id, invokeOnChildCallbacks, invokeOnEnterCallbacks, invokeOnExitCallbacks, isTimedOut, localAddress, log, logBuilder, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, mapCurrent, meterRegistry, method, onChild, onEnter, onEnter, onExit, onExit, path, push, push, push, push, pushIfAbsent, query, rejectPromise, remoteAddress, resolvePromise, sessionProtocol, sslSession, updateRequest, updateRpcRequestprotected ClientRequestContextWrapper(ClientRequestContext delegate)
public ClientRequestContext newDerivedContext(RequestId id, @Nullable HttpRequest req, @Nullable RpcRequest rpcReq, Endpoint endpoint)
ClientRequestContextClientRequestContext whose properties and Attributes are copied from this
ClientRequestContext, except having different Request, Endpoint and its own
RequestLog.newDerivedContext in interface ClientRequestContextpublic EndpointSelector endpointSelector()
ClientRequestContextEndpointSelector used for the current Request.endpointSelector in interface ClientRequestContextEndpointSelector if a user specified a group Endpoint.
null if a user specified a host Endpoint.public Endpoint endpoint()
ClientRequestContextendpoint in interface ClientRequestContextEndpoint. null if the Request has failed
because its remote Endpoint couldn't be determined.public String fragment()
ClientRequestContextRequest, as defined in
the section 3.5 of RFC3986.fragment in interface ClientRequestContextnull if no fragment was specifiedpublic ClientOptions options()
ClientRequestContextClientOptions of the current Request.options in interface ClientRequestContextpublic long writeTimeoutMillis()
ClientRequestContextRequest
succeeds. This value is initially set from ClientOption.WRITE_TIMEOUT_MILLIS.writeTimeoutMillis in interface ClientRequestContextpublic void setWriteTimeoutMillis(long writeTimeoutMillis)
ClientRequestContextRequest
succeeds. This value is initially set from ClientOption.WRITE_TIMEOUT_MILLIS.setWriteTimeoutMillis in interface ClientRequestContextpublic void setWriteTimeout(Duration writeTimeout)
ClientRequestContextRequest
succeeds. This value is initially set from ClientOption.WRITE_TIMEOUT_MILLIS.setWriteTimeout in interface ClientRequestContextpublic long responseTimeoutMillis()
ClientRequestContextResponse completely
since the transfer of the Response started. This value is initially set from
ClientOption.RESPONSE_TIMEOUT_MILLIS.responseTimeoutMillis in interface ClientRequestContextpublic void setResponseTimeoutMillis(long responseTimeoutMillis)
ClientRequestContextResponse completely
since the transfer of the Response started. This value is initially set from
ClientOption.RESPONSE_TIMEOUT_MILLIS.setResponseTimeoutMillis in interface ClientRequestContextpublic void setResponseTimeout(Duration responseTimeout)
ClientRequestContextResponse completely
since the transfer of the Response started. This value is initially set from
ClientOption.RESPONSE_TIMEOUT_MILLIS.setResponseTimeout in interface ClientRequestContext@Nullable public Runnable responseTimeoutHandler()
ClientRequestContextResponse timeout handler which is executed when
the Response is not completely received within the allowed ClientRequestContext.responseTimeoutMillis()
or the default ClientOption.RESPONSE_TIMEOUT_MILLIS.responseTimeoutHandler in interface ClientRequestContextpublic void setResponseTimeoutHandler(Runnable responseTimeoutHandler)
ClientRequestContextresponseTimeoutHandler must abort
the response, e.g., by calling StreamMessage.abort(Throwable).
If not set, the response will be closed with ResponseTimeoutException.
For example,
HttpResponseWriter res = HttpResponse.streaming();
ctx.setResponseTimeoutHandler(() -> {
res.abort(new IllegalStateException("Server is in a bad state."));
});
...
setResponseTimeoutHandler in interface ClientRequestContextpublic long maxResponseLength()
ClientRequestContextResponse.
This value is initially set from ClientOption.MAX_RESPONSE_LENGTH.maxResponseLength in interface ClientRequestContextContentTooLargeExceptionpublic void setMaxResponseLength(long maxResponseLength)
ClientRequestContextResponse.
This value is initially set from ClientOption.MAX_RESPONSE_LENGTH.setMaxResponseLength in interface ClientRequestContextContentTooLargeExceptionpublic HttpHeaders additionalRequestHeaders()
ClientRequestContextadditionalRequestHeaders in interface ClientRequestContextpublic void setAdditionalRequestHeader(CharSequence name, Object value)
ClientRequestContextname and value. This will remove all previous values
associated with the specified name.
The header will be included when a Client sends an HttpRequest.setAdditionalRequestHeader in interface ClientRequestContextpublic void setAdditionalRequestHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
ClientRequestContextHttpHeaders which is included when a
Client sends an HttpRequest.setAdditionalRequestHeaders in interface ClientRequestContextpublic void addAdditionalRequestHeader(CharSequence name, Object value)
ClientRequestContextname and value. The header will be included when
a Client sends an HttpRequest.addAdditionalRequestHeader in interface ClientRequestContextpublic void addAdditionalRequestHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
ClientRequestContextaddAdditionalRequestHeaders in interface ClientRequestContextpublic boolean removeAdditionalRequestHeader(CharSequence name)
ClientRequestContextname.removeAdditionalRequestHeader in interface ClientRequestContexttrue if at least one entry has been removedCopyright © 2020 LeanCloud. All rights reserved.