Class HttpRequest

java.lang.Object
com.yahoo.jdisc.AbstractResource
com.yahoo.jdisc.Request
com.yahoo.jdisc.http.HttpRequest
All Implemented Interfaces:
com.yahoo.jdisc.SharedResource

public class HttpRequest extends com.yahoo.jdisc.Request
A HTTP request.
Author:
Anirudha Khanna, Einar M R Rosenvinge
  • Constructor Details

  • Method Details

    • getMethod

      public HttpRequest.Method getMethod()
    • setMethod

      public void setMethod(HttpRequest.Method method)
    • getVersion

      public HttpRequest.Version getVersion()
    • getRemoteHostAddress

      public String getRemoteHostAddress()
      Returns the remote address, or null if unresolved
    • getRemoteHostName

      public String getRemoteHostName()
    • getRemotePort

      public int getRemotePort()
    • setVersion

      public void setVersion(HttpRequest.Version version)
    • getRemoteAddress

      public SocketAddress getRemoteAddress()
    • setRemoteAddress

      public void setRemoteAddress(SocketAddress remoteAddress)
    • getProxyServer

      public URI getProxyServer()
    • setProxyServer

      public void setProxyServer(URI proxyServer)
    • getConnectedAt

      public long getConnectedAt(TimeUnit unit)

      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

      public Long getConnectionTimeout(TimeUnit unit)
    • setConnectionTimeout

      public void setConnectionTimeout(long timeout, TimeUnit unit)

      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 a ResponseHandler, 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

      public Map<String,List<String>> parameters()
    • copyHeaders

      public void copyHeaders(com.yahoo.jdisc.HeaderFields target)
    • decodeCookieHeader

      public List<Cookie> decodeCookieHeader()
    • encodeCookieHeader

      public void encodeCookieHeader(List<Cookie> cookies)
    • 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 calling Request.connect(ResponseHandler). You must NOT WRITE to these headers AFTER calling ContentChannel.close(CompletionHandler), and you must NOT READ from these headers BEFORE ContentChannel.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 for ContentChannel.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

      public Principal getUserPrincipal()
    • setUserPrincipal

      public void setUserPrincipal(Principal principal)
    • 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

      public static HttpRequest newClientRequest(com.yahoo.jdisc.Request parent, URI uri)
    • 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)