Class HttpRequest
- All Implemented Interfaces:
com.yahoo.jdisc.SharedResource
- Author:
- Anirudha Khanna, Einar M R Rosenvinge
-
Nested Class Summary
Nested classes/interfaces inherited from class com.yahoo.jdisc.Request
com.yahoo.jdisc.Request.RequestType
Nested classes/interfaces inherited from interface com.yahoo.jdisc.SharedResource
com.yahoo.jdisc.SharedResource.Debug
-
Field Summary
Fields inherited from interface com.yahoo.jdisc.SharedResource
DEBUG, SYSTEM_PROPERTY_NAME_DEBUG
-
Constructor Summary
ModifierConstructorDescriptionprotected
HttpRequest
(com.yahoo.jdisc.service.CurrentContainer container, URI uri, HttpRequest.Method method, HttpRequest.Version version, SocketAddress remoteAddress, Long connectedAtMillis) -
Method Summary
Modifier and TypeMethodDescriptionvoid
copyHeaders
(com.yahoo.jdisc.HeaderFields target) void
encodeCookieHeader
(List<Cookie> cookies) long
getConnectedAt
(TimeUnit unit) For server requests, this returns the timestamp of when the underlying HTTP channel was connected.getConnectionTimeout
(TimeUnit unit) Returns the remote address, or null if unresolvedint
boolean
boolean
Returns whether this request was explicitly chunked from the client. NOTE that there are cases where the underlying HTTP server library (Netty for the time being) will read the request in a chunked manner.boolean
static HttpRequest
newClientRequest
(com.yahoo.jdisc.Request parent, URI uri) static HttpRequest
newClientRequest
(com.yahoo.jdisc.Request parent, URI uri, HttpRequest.Method method) static HttpRequest
newClientRequest
(com.yahoo.jdisc.Request parent, URI uri, HttpRequest.Method method, HttpRequest.Version version) static HttpRequest
newServerRequest
(com.yahoo.jdisc.service.CurrentContainer container, URI uri) static HttpRequest
newServerRequest
(com.yahoo.jdisc.service.CurrentContainer container, URI uri, HttpRequest.Method method) static HttpRequest
newServerRequest
(com.yahoo.jdisc.service.CurrentContainer container, URI uri, HttpRequest.Method method, HttpRequest.Version version) static HttpRequest
newServerRequest
(com.yahoo.jdisc.service.CurrentContainer container, URI uri, HttpRequest.Method method, HttpRequest.Version version, SocketAddress remoteAddress) static HttpRequest
newServerRequest
(com.yahoo.jdisc.service.CurrentContainer container, URI uri, HttpRequest.Method method, HttpRequest.Version version, SocketAddress remoteAddress, long connectedAtMillis) long
void
setConnectionTimeout
(long timeout, TimeUnit unit) Sets the allocated time that this HttpRequest is allowed to spend trying to connect to a remote host.void
setMethod
(HttpRequest.Method method) void
setProxyServer
(URI proxyServer) void
setRemoteAddress
(SocketAddress remoteAddress) void
setUserPrincipal
(Principal principal) void
setVersion
(HttpRequest.Version version) com.yahoo.jdisc.HeaderFields
trailers()
Returns the set of trailer header fields of this HttpRequest.Methods inherited from class com.yahoo.jdisc.Request
cancel, connect, container, context, creationTime, destroy, getBindingMatch, getTimeout, getTimeoutManager, getUri, headers, isCancelled, isServerRequest, setBindingMatch, setServerRequest, setTimeout, setTimeoutManager, setUri, timeElapsed, timeRemaining
Methods inherited from class com.yahoo.jdisc.AbstractResource
currentState, refer, refer, release, retainCount
-
Constructor Details
-
HttpRequest
protected HttpRequest(com.yahoo.jdisc.service.CurrentContainer container, URI uri, HttpRequest.Method method, HttpRequest.Version version, SocketAddress remoteAddress, Long connectedAtMillis)
-
-
Method Details
-
getMethod
-
setMethod
-
getVersion
-
getRemoteHostAddress
Returns the remote address, or null if unresolved -
getRemoteHostName
-
getRemotePort
public int getRemotePort() -
setVersion
-
getRemoteAddress
-
setRemoteAddress
-
getProxyServer
-
setProxyServer
-
getConnectedAt
For server requests, this returns the timestamp of when the underlying HTTP channel was connected.
For client requests, this returns the same value as
Request.creationTime(java.util.concurrent.TimeUnit)
.- Parameters:
unit
- the unit to return the time in- Returns:
- the timestamp of when the underlying HTTP channel was connected, or request creation time
-
getConnectionTimeout
-
setConnectionTimeout
Sets the allocated time that this HttpRequest is allowed to spend trying to connect to a remote host. This has no effect on an HttpRequest received by a
RequestHandler
. If no connection timeout is assigned to an HttpRequest, it defaults the connection-timeout in the client configuration.NOTE: Where
Request.setTimeout(long, TimeUnit)
sets the expiration time between calling a RequestHandler and aResponseHandler
, this method sets the expiration time of the connect-operation as performed by the client.- Parameters:
timeout
- The allocated amount of time.unit
- The time unit of the timeout argument.
-
parameters
-
copyHeaders
public void copyHeaders(com.yahoo.jdisc.HeaderFields target) -
decodeCookieHeader
-
encodeCookieHeader
-
trailers
public com.yahoo.jdisc.HeaderFields trailers()Returns the set of trailer header fields of this HttpRequest. These are typically meta-data that should have been part of
Request.headers()
, but were not available prior to callingRequest.connect(ResponseHandler)
. You must NOT WRITE to these headers AFTER callingContentChannel.close(CompletionHandler)
, and you must NOT READ from these headers BEFOREContentChannel.close(CompletionHandler)
has been called.NOTE: These headers are NOT thread-safe. You need to explicitly synchronized on the returned object to prevent concurrency issues such as ConcurrentModificationExceptions.
- Returns:
- The trailer headers of this HttpRequest.
-
isChunked
public boolean isChunked()Returns whether this request was explicitly chunked from the client. NOTE that there are cases where the underlying HTTP server library (Netty for the time being) will read the request in a chunked manner. An application MUST wait forContentChannel.close(com.yahoo.jdisc.handler.CompletionHandler)
before it can actually know that it has received the entire request.- Returns:
- true if this request was chunked from the client.
-
hasChunkedResponse
public boolean hasChunkedResponse() -
isKeepAlive
public boolean isKeepAlive() -
relativeCreatedAtNanoTime
public long relativeCreatedAtNanoTime()- Returns:
- the relative created timestamp (using
System.nanoTime()
-
getUserPrincipal
-
setUserPrincipal
-
newServerRequest
public static HttpRequest newServerRequest(com.yahoo.jdisc.service.CurrentContainer container, URI uri) -
newServerRequest
public static HttpRequest newServerRequest(com.yahoo.jdisc.service.CurrentContainer container, URI uri, HttpRequest.Method method) -
newServerRequest
public static HttpRequest newServerRequest(com.yahoo.jdisc.service.CurrentContainer container, URI uri, HttpRequest.Method method, HttpRequest.Version version) -
newServerRequest
public static HttpRequest newServerRequest(com.yahoo.jdisc.service.CurrentContainer container, URI uri, HttpRequest.Method method, HttpRequest.Version version, SocketAddress remoteAddress) -
newServerRequest
public static HttpRequest newServerRequest(com.yahoo.jdisc.service.CurrentContainer container, URI uri, HttpRequest.Method method, HttpRequest.Version version, SocketAddress remoteAddress, long connectedAtMillis) -
newClientRequest
-
newClientRequest
public static HttpRequest newClientRequest(com.yahoo.jdisc.Request parent, URI uri, HttpRequest.Method method) -
newClientRequest
public static HttpRequest newClientRequest(com.yahoo.jdisc.Request parent, URI uri, HttpRequest.Method method, HttpRequest.Version version)
-