org.apache.coyote

Class 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: Tomcat defines a number of attributes:

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
Request()
Method Summary
voidaction(ActionCode actionCode, Object param)
MessageBytescontentType()
MessageBytesdecodedURI()
intdoRead(ByteChunk chunk)
Read data from the input buffer and put it into a byte chunk.
ObjectgetAttribute(String name)
HashMapgetAttributes()
MessageBytesgetAuthType()
intgetAvailable()
intgetBytesRead()
StringgetCharacterEncoding()
Get the character encoding used for this request.
intgetContentLength()
longgetContentLengthLong()
StringgetContentType()
CookiesgetCookies()
StringgetHeader(String name)
InputBuffergetInputBuffer()
intgetLocalPort()
MimeHeadersgetMimeHeaders()
ObjectgetNote(int pos)
ParametersgetParameters()
intgetRemotePort()
MessageBytesgetRemoteUser()
RequestInfogetRequestProcessor()
ResponsegetResponse()
intgetServerPort()
longgetStartTime()
UDecodergetURLDecoder()
MessageBytesinstanceId()
Get the instance id (or JVM route).
MessageByteslocalAddr()
MessageByteslocalName()
MessageBytesmethod()
MessageBytesprotocol()
MessageBytesquery()
MessageBytesqueryString()
voidrecycle()
MessageBytesremoteAddr()
MessageBytesremoteHost()
MessageBytesrequestURI()
MessageBytesscheme()
MessageBytesserverName()
Return the buffer holding the server name, if any.
voidsetAttribute(String name, Object o)
voidsetAvailable(int available)
voidsetBytesRead(int bytesRead)
voidsetCharacterEncoding(String enc)
voidsetContentLength(int len)
voidsetContentType(String type)
voidsetContentType(MessageBytes mb)
voidsetInputBuffer(InputBuffer inputBuffer)
voidsetLocalPort(int port)
voidsetNote(int pos, Object value)
Used to store private data.
voidsetRemotePort(int port)
voidsetResponse(Response response)
voidsetServerPort(int serverPort)
voidsetStartTime(long startTime)
StringtoString()
MessageBytesunparsedURI()
voidupdateCounters()

Constructor Detail

Request

public Request()

Method Detail

action

public void action(ActionCode actionCode, Object param)

contentType

public MessageBytes contentType()

decodedURI

public MessageBytes decodedURI()

doRead

public int doRead(ByteChunk chunk)
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.

getAttribute

public Object getAttribute(String name)

getAttributes

public HashMap getAttributes()

getAuthType

public MessageBytes getAuthType()

getAvailable

public int getAvailable()

getBytesRead

public int getBytesRead()

getCharacterEncoding

public String getCharacterEncoding()
Get the character encoding used for this request.

getContentLength

public int getContentLength()

getContentLengthLong

public long getContentLengthLong()

getContentType

public String getContentType()

getCookies

public Cookies getCookies()

getHeader

public String getHeader(String name)

getInputBuffer

public InputBuffer getInputBuffer()

getLocalPort

public int getLocalPort()

getMimeHeaders

public MimeHeaders getMimeHeaders()

getNote

public final Object getNote(int pos)

getParameters

public Parameters getParameters()

getRemotePort

public int getRemotePort()

getRemoteUser

public MessageBytes getRemoteUser()

getRequestProcessor

public RequestInfo getRequestProcessor()

getResponse

public Response getResponse()

getServerPort

public int getServerPort()

getStartTime

public long getStartTime()

getURLDecoder

public UDecoder getURLDecoder()

instanceId

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

Returns: the instance id

localAddr

public MessageBytes localAddr()

localName

public MessageBytes localName()

method

public MessageBytes method()

protocol

public MessageBytes protocol()

query

public MessageBytes query()

queryString

public MessageBytes queryString()

recycle

public void recycle()

remoteAddr

public MessageBytes remoteAddr()

remoteHost

public MessageBytes remoteHost()

requestURI

public MessageBytes requestURI()

scheme

public MessageBytes scheme()

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.

setAttribute

public void setAttribute(String name, Object o)

setAvailable

public void setAvailable(int available)

setBytesRead

public void setBytesRead(int bytesRead)

setCharacterEncoding

public void setCharacterEncoding(String enc)

setContentLength

public void setContentLength(int len)

setContentType

public void setContentType(String type)

setContentType

public void setContentType(MessageBytes mb)

setInputBuffer

public void setInputBuffer(InputBuffer inputBuffer)

setLocalPort

public void setLocalPort(int port)

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.

setRemotePort

public void setRemotePort(int port)

setResponse

public void setResponse(Response response)

setServerPort

public void setServerPort(int serverPort)

setStartTime

public void setStartTime(long startTime)

toString

public String toString()

unparsedURI

public MessageBytes unparsedURI()

updateCounters

public void updateCounters()
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.