Package com.linecorp.armeria.client
Class ClientRequestContextWrapper
- java.lang.Object
-
- com.linecorp.armeria.common.AbstractRequestContext
-
- com.linecorp.armeria.common.RequestContextWrapper<ClientRequestContext>
-
- com.linecorp.armeria.client.ClientRequestContextWrapper
-
- All Implemented Interfaces:
ClientRequestContext
,RequestContext
,AttributeMap
public class ClientRequestContextWrapper extends RequestContextWrapper<ClientRequestContext> implements ClientRequestContext
Wraps an existingClientRequestContext
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ClientRequestContextWrapper(ClientRequestContext delegate)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAdditionalRequestHeader(CharSequence name, Object value)
Adds a header with the specifiedname
andvalue
.void
addAdditionalRequestHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
HttpHeaders
additionalRequestHeaders()
Endpoint
endpoint()
EndpointSelector
endpointSelector()
Returns theEndpointSelector
used for the currentRequest
.String
fragment()
Returns the fragment part of the URI of the currentRequest
, as defined in the section 3.5 of RFC3986.long
maxResponseLength()
Returns the maximum length of the receivedResponse
.ClientRequestContext
newDerivedContext()
Creates a newClientRequestContext
whose properties andAttribute
s are copied from thisClientRequestContext
, except having its ownRequestLog
.ClientRequestContext
newDerivedContext(Request request)
Creates a newClientRequestContext
whose properties andAttribute
s are copied from thisClientRequestContext
, except having a differentRequest
and its ownRequestLog
.ClientRequestContext
newDerivedContext(Request request, Endpoint endpoint)
Creates a newClientRequestContext
whose properties andAttribute
s are copied from thisClientRequestContext
, except having differentRequest
,Endpoint
and its ownRequestLog
.ClientOptions
options()
Returns theClientOptions
of the currentRequest
.boolean
removeAdditionalRequestHeader(CharSequence name)
Removes all headers with the specifiedname
.long
responseTimeoutMillis()
void
setAdditionalRequestHeader(CharSequence name, Object value)
Sets a header with the specifiedname
andvalue
.void
setAdditionalRequestHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Clears the current header and sets the specifiedHttpHeaders
which is included when aClient
sends anHttpRequest
.void
setMaxResponseLength(long maxResponseLength)
Sets the maximum length of the receivedResponse
.void
setResponseTimeout(Duration responseTimeout)
void
setResponseTimeoutMillis(long responseTimeoutMillis)
void
setWriteTimeout(Duration writeTimeout)
Returns the amount of time allowed until the initial write attempt of the currentRequest
succeeds.void
setWriteTimeoutMillis(long writeTimeoutMillis)
Returns the amount of time allowed until the initial write attempt of the currentRequest
succeeds.long
writeTimeoutMillis()
Returns the amount of time allowed until the initial write attempt of the currentRequest
succeeds.-
Methods inherited from class com.linecorp.armeria.common.RequestContextWrapper
alloc, attr, attrs, decodedPath, delegate, eventLoop, hasAttr, invokeOnChildCallbacks, invokeOnEnterCallbacks, invokeOnExitCallbacks, localAddress, log, logBuilder, meterRegistry, method, onChild, onEnter, onExit, path, query, remoteAddress, request, sessionProtocol, sslSession, updateRequest
-
Methods inherited from class com.linecorp.armeria.common.AbstractRequestContext
contextAwareEventLoop, equals, hashCode, isTimedOut, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, onEnter, onExit, rejectPromise, resolvePromise, setTimedOut
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.util.AttributeMap
attr, hasAttr
-
Methods inherited from interface com.linecorp.armeria.common.RequestContext
alloc, attrs, contextAwareEventLoop, contextAwareExecutor, decodedPath, eventLoop, executor, invokeOnChildCallbacks, invokeOnEnterCallbacks, invokeOnExitCallbacks, isTimedOut, localAddress, log, logBuilder, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, meterRegistry, method, onChild, onEnter, onEnter, onExit, onExit, path, push, push, pushIfAbsent, query, rejectPromise, remoteAddress, request, resolvePromise, sessionProtocol, sslSession, updateRequest
-
-
-
-
Constructor Detail
-
ClientRequestContextWrapper
protected ClientRequestContextWrapper(ClientRequestContext delegate)
Creates a new instance.
-
-
Method Detail
-
newDerivedContext
public ClientRequestContext newDerivedContext()
Description copied from interface:ClientRequestContext
Creates a newClientRequestContext
whose properties andAttribute
s are copied from thisClientRequestContext
, except having its ownRequestLog
.- Specified by:
newDerivedContext
in interfaceClientRequestContext
- Specified by:
newDerivedContext
in interfaceRequestContext
-
newDerivedContext
public ClientRequestContext newDerivedContext(Request request)
Description copied from interface:ClientRequestContext
Creates a newClientRequestContext
whose properties andAttribute
s are copied from thisClientRequestContext
, except having a differentRequest
and its ownRequestLog
.- Specified by:
newDerivedContext
in interfaceClientRequestContext
- Specified by:
newDerivedContext
in interfaceRequestContext
-
newDerivedContext
public ClientRequestContext newDerivedContext(Request request, Endpoint endpoint)
Description copied from interface:ClientRequestContext
Creates a newClientRequestContext
whose properties andAttribute
s are copied from thisClientRequestContext
, except having differentRequest
,Endpoint
and its ownRequestLog
.- Specified by:
newDerivedContext
in interfaceClientRequestContext
-
endpointSelector
public EndpointSelector endpointSelector()
Description copied from interface:ClientRequestContext
Returns theEndpointSelector
used for the currentRequest
.- Specified by:
endpointSelector
in interfaceClientRequestContext
- Returns:
- the
EndpointSelector
if a user specified a groupEndpoint
.null
if a user specified a hostEndpoint
.
-
endpoint
public Endpoint endpoint()
Description copied from interface:ClientRequestContext
- Specified by:
endpoint
in interfaceClientRequestContext
- Returns:
- the remote
Endpoint
.null
if theRequest
has failed because its remoteEndpoint
couldn't be determined.
-
fragment
public String fragment()
Description copied from interface:ClientRequestContext
Returns the fragment part of the URI of the currentRequest
, as defined in the section 3.5 of RFC3986.- Specified by:
fragment
in interfaceClientRequestContext
- Returns:
- the fragment part of the request URI, or
null
if no fragment was specified
-
options
public ClientOptions options()
Description copied from interface:ClientRequestContext
Returns theClientOptions
of the currentRequest
.- Specified by:
options
in interfaceClientRequestContext
-
writeTimeoutMillis
public long writeTimeoutMillis()
Description copied from interface:ClientRequestContext
Returns the amount of time allowed until the initial write attempt of the currentRequest
succeeds. This value is initially set fromClientOption.WRITE_TIMEOUT_MILLIS
.- Specified by:
writeTimeoutMillis
in interfaceClientRequestContext
-
setWriteTimeoutMillis
public void setWriteTimeoutMillis(long writeTimeoutMillis)
Description copied from interface:ClientRequestContext
Returns the amount of time allowed until the initial write attempt of the currentRequest
succeeds. This value is initially set fromClientOption.WRITE_TIMEOUT_MILLIS
.- Specified by:
setWriteTimeoutMillis
in interfaceClientRequestContext
-
setWriteTimeout
public void setWriteTimeout(Duration writeTimeout)
Description copied from interface:ClientRequestContext
Returns the amount of time allowed until the initial write attempt of the currentRequest
succeeds. This value is initially set fromClientOption.WRITE_TIMEOUT_MILLIS
.- Specified by:
setWriteTimeout
in interfaceClientRequestContext
-
responseTimeoutMillis
public long responseTimeoutMillis()
Description copied from interface:ClientRequestContext
Returns the amount of time allowed until receiving theResponse
completely since the transfer of theResponse
started. This value is initially set fromClientOption.RESPONSE_TIMEOUT_MILLIS
.- Specified by:
responseTimeoutMillis
in interfaceClientRequestContext
-
setResponseTimeoutMillis
public void setResponseTimeoutMillis(long responseTimeoutMillis)
Description copied from interface:ClientRequestContext
Sets the amount of time allowed until receiving theResponse
completely since the transfer of theResponse
started. This value is initially set fromClientOption.RESPONSE_TIMEOUT_MILLIS
.- Specified by:
setResponseTimeoutMillis
in interfaceClientRequestContext
-
setResponseTimeout
public void setResponseTimeout(Duration responseTimeout)
Description copied from interface:ClientRequestContext
Sets the amount of time allowed until receiving theResponse
completely since the transfer of theResponse
started. This value is initially set fromClientOption.RESPONSE_TIMEOUT_MILLIS
.- Specified by:
setResponseTimeout
in interfaceClientRequestContext
-
maxResponseLength
public long maxResponseLength()
Description copied from interface:ClientRequestContext
Returns the maximum length of the receivedResponse
. This value is initially set fromClientOption.MAX_RESPONSE_LENGTH
.- Specified by:
maxResponseLength
in interfaceClientRequestContext
- See Also:
ContentTooLargeException
-
setMaxResponseLength
public void setMaxResponseLength(long maxResponseLength)
Description copied from interface:ClientRequestContext
Sets the maximum length of the receivedResponse
. This value is initially set fromClientOption.MAX_RESPONSE_LENGTH
.- Specified by:
setMaxResponseLength
in interfaceClientRequestContext
- See Also:
ContentTooLargeException
-
additionalRequestHeaders
public HttpHeaders additionalRequestHeaders()
Description copied from interface:ClientRequestContext
- Specified by:
additionalRequestHeaders
in interfaceClientRequestContext
-
setAdditionalRequestHeader
public void setAdditionalRequestHeader(CharSequence name, Object value)
Description copied from interface:ClientRequestContext
Sets a header with the specifiedname
andvalue
. This will remove all previous values associated with the specifiedname
. The header will be included when aClient
sends anHttpRequest
.- Specified by:
setAdditionalRequestHeader
in interfaceClientRequestContext
-
setAdditionalRequestHeaders
public void setAdditionalRequestHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Description copied from interface:ClientRequestContext
Clears the current header and sets the specifiedHttpHeaders
which is included when aClient
sends anHttpRequest
.- Specified by:
setAdditionalRequestHeaders
in interfaceClientRequestContext
-
addAdditionalRequestHeader
public void addAdditionalRequestHeader(CharSequence name, Object value)
Description copied from interface:ClientRequestContext
Adds a header with the specifiedname
andvalue
. The header will be included when aClient
sends anHttpRequest
.- Specified by:
addAdditionalRequestHeader
in interfaceClientRequestContext
-
addAdditionalRequestHeaders
public void addAdditionalRequestHeaders(Iterable<? extends Map.Entry<? extends CharSequence,?>> headers)
Description copied from interface:ClientRequestContext
- Specified by:
addAdditionalRequestHeaders
in interfaceClientRequestContext
-
removeAdditionalRequestHeader
public boolean removeAdditionalRequestHeader(CharSequence name)
Description copied from interface:ClientRequestContext
Removes all headers with the specifiedname
.- Specified by:
removeAdditionalRequestHeader
in interfaceClientRequestContext
- Returns:
true
if at least one entry has been removed
-
-