org.apache.coyote

## Class Request

- java.lang.Object
- - org.apache.coyote.Request

-     public final class Request
      extends Object

  This is a low-level, efficient representation of a server request. Most fields are GC-free, expensive operations are delayed until the user code needs the information. Processing is delegated to modules, using a hook mechanism. This class is not intended for user code - it is used internally by tomcat for processing the request in the most efficient way. Users ( servlets ) can access the information using a facade, which provides the high-level view of the request. For lazy evaluation, the request uses the getInfo() hook. The following ids are defined:
  - req.encoding - returns the request encoding
  - req.attribute - returns a module-specific attribute ( like SSL keys, etc ).
  Tomcat defines a number of attributes:
  - "org.apache.tomcat.request" - allows access to the low-level request object in trusted applications
  Author:
    James Duncan Davidson [duncan@eng.sun.com], James Todd [gonzo@eng.sun.com], Jason Hunter [jch@eng.sun.com], Harish Prabandham, Alex Cruikshank [alex@epitonic.com], Hans Bergsten [hans@gefionsoftware.com], Costin Manolache, Remy Maucherat

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Request()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `action(ActionCode actionCode, Object param)`
    `MessageBytes` | `contentType()`
    `MessageBytes` | `decodedURI()`
    `int` | `doRead(ByteChunk chunk)` Read data from the input buffer and put it into a byte chunk.
    `Object` | `getAttribute(String name)`
    `HashMap<String,Object>` | `getAttributes()`
    `MessageBytes` | `getAuthType()`
    `int` | `getAvailable()`
    `long` | `getBytesRead()`
    `String` | `getCharacterEncoding()` Get the character encoding used for this request.
    `int` | `getContentLength()`
    `long` | `getContentLengthLong()`
    `String` | `getContentType()`
    `Cookies` | `getCookies()`
    `String` | `getHeader(String name)`
    `InputBuffer` | `getInputBuffer()`
    `int` | `getLocalPort()`
    `MimeHeaders` | `getMimeHeaders()`
    `Object` | `getNote(int pos)`
    `Parameters` | `getParameters()`
    `int` | `getRemotePort()`
    `MessageBytes` | `getRemoteUser()`
    `boolean` | `getRemoteUserNeedsAuthorization()`
    `RequestInfo` | `getRequestProcessor()`
    `Response` | `getResponse()`
    `int` | `getServerPort()`
    `long` | `getStartTime()`
    `boolean` | `getSupportsRelativeRedirects()`
    `UDecoder` | `getURLDecoder()`
    `MessageBytes` | `instanceId()` Get the instance id (or JVM route).
    `boolean` | `isProcessing()`
    `MessageBytes` | `localAddr()`
    `MessageBytes` | `localName()`
    `MessageBytes` | `method()`
    `MessageBytes` | `protocol()`
    `MessageBytes` | `queryString()`
    `void` | `recycle()`
    `MessageBytes` | `remoteAddr()`
    `MessageBytes` | `remoteHost()`
    `MessageBytes` | `requestURI()`
    `MessageBytes` | `scheme()`
    `MessageBytes` | `serverName()` Return the buffer holding the server name, if any.
    `void` | `setAttribute(String name, Object o)`
    `void` | `setAvailable(int available)`
    `void` | `setCharacterEncoding(String enc)`
    `void` | `setContentLength(long len)`
    `void` | `setContentType(MessageBytes mb)`
    `void` | `setContentType(String type)`
    `void` | `setInputBuffer(InputBuffer inputBuffer)`
    `void` | `setLocalPort(int port)`
    `void` | `setNote(int pos, Object value)` Used to store private data.
    `void` | `setRemotePort(int port)`
    `void` | `setRemoteUserNeedsAuthorization(boolean remoteUserNeedsAuthorization)`
    `void` | `setResponse(Response response)`
    `void` | `setServerPort(int serverPort)`
    `void` | `setStartTime(long startTime)`
    `String` | `toString()`
    `MessageBytes` | `unparsedURI()`
    `void` | `updateCounters()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Request

          public Request()

  - ### Method Detail

    - #### instanceId

          public MessageBytes instanceId()

      Get the instance id (or JVM route). Currently Ajp is sending it with each request. In future this should be fixed, and sent only once ( or 'negotiated' at config time so both tomcat and apache share the same name.
      Returns:
        the instance id

    - #### getMimeHeaders

          public MimeHeaders getMimeHeaders()

    - #### getURLDecoder

          public UDecoder getURLDecoder()

    - #### scheme

          public MessageBytes scheme()

    - #### method

          public MessageBytes method()

    - #### unparsedURI

          public MessageBytes unparsedURI()

    - #### requestURI

          public MessageBytes requestURI()

    - #### decodedURI

          public MessageBytes decodedURI()

    - #### queryString

          public MessageBytes queryString()

    - #### protocol

          public MessageBytes protocol()

    - #### serverName

          public MessageBytes serverName()

      Return the buffer holding the server name, if any. Use isNull() to check if there is no value set. This is the "virtual host", derived from the Host: header.

    - #### getServerPort

          public int getServerPort()

    - #### setServerPort

          public void setServerPort(int serverPort)

    - #### remoteAddr

          public MessageBytes remoteAddr()

    - #### remoteHost

          public MessageBytes remoteHost()

    - #### localName

          public MessageBytes localName()

    - #### localAddr

          public MessageBytes localAddr()

    - #### getRemotePort

          public int getRemotePort()

    - #### setRemotePort

          public void setRemotePort(int port)

    - #### getLocalPort

          public int getLocalPort()

    - #### setLocalPort

          public void setLocalPort(int port)

    - #### getCharacterEncoding

          public String getCharacterEncoding()

      Get the character encoding used for this request.

    - #### setCharacterEncoding

          public void setCharacterEncoding(String enc)

    - #### setContentLength

          public void setContentLength(long len)

    - #### getContentLength

          public int getContentLength()

    - #### getContentLengthLong

          public long getContentLengthLong()

    - #### getContentType

          public String getContentType()

    - #### setContentType

          public void setContentType(String type)

    - #### contentType

          public MessageBytes contentType()

    - #### setContentType

          public void setContentType(MessageBytes mb)

    - #### getHeader

          public String getHeader(String name)

    - #### getResponse

          public Response getResponse()

    - #### setResponse

          public void setResponse(Response response)

    - #### action

          public void action(ActionCode actionCode,
                    Object param)

    - #### getCookies

          public Cookies getCookies()

    - #### getParameters

          public Parameters getParameters()

    - #### setAttribute

          public void setAttribute(String name,
                          Object o)

    - #### getAttributes

          public HashMap<String,Object> getAttributes()

    - #### getAttribute

          public Object getAttribute(String name)

    - #### getRemoteUser

          public MessageBytes getRemoteUser()

    - #### getRemoteUserNeedsAuthorization

          public boolean getRemoteUserNeedsAuthorization()

    - #### setRemoteUserNeedsAuthorization

          public void setRemoteUserNeedsAuthorization(boolean remoteUserNeedsAuthorization)

    - #### getAuthType

          public MessageBytes getAuthType()

    - #### getAvailable

          public int getAvailable()

    - #### setAvailable

          public void setAvailable(int available)

    - #### getSupportsRelativeRedirects

          public boolean getSupportsRelativeRedirects()

    - #### getInputBuffer

          public InputBuffer getInputBuffer()

    - #### setInputBuffer

          public void setInputBuffer(InputBuffer inputBuffer)

    - #### doRead

          public int doRead(ByteChunk chunk)
                     throws IOException

      Read data from the input buffer and put it into a byte chunk. The buffer is owned by the protocol implementation - it will be reused on the next read. The Adapter must either process the data in place or copy it to a separate buffer if it needs to hold it. In most cases this is done during byte->char conversions or via InputStream. Unlike InputStream, this interface allows the app to process data in place, without copy.
      Throws:
        `IOException`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getStartTime

          public long getStartTime()

    - #### setStartTime

          public void setStartTime(long startTime)

    - #### setNote

          public final void setNote(int pos,
                     Object value)

      Used to store private data. Thread data could be used instead - but if you have the req, getting/setting a note is just a array access, may be faster than ThreadLocal for very frequent operations. Example use: Jk: HandlerRequest.HOSTBUFFER = 10 CharChunk, buffer for Host decoding WorkerEnv: SSL_CERT_NOTE=16 - MessageBytes containing the cert Catalina CoyoteAdapter: ADAPTER_NOTES = 1 - stores the HttpServletRequest object ( req/res) To avoid conflicts, note in the range 0 - 8 are reserved for the servlet container ( catalina connector, etc ), and values in 9 - 16 for connector use. 17-31 range is not allocated or used.

    - #### getNote

          public final Object getNote(int pos)

    - #### recycle

          public void recycle()

    - #### updateCounters

          public void updateCounters()

    - #### getRequestProcessor

          public RequestInfo getRequestProcessor()

    - #### getBytesRead

          public long getBytesRead()

    - #### isProcessing

          public boolean isProcessing()

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.