Package org.apache.coyote
Class Request
- java.lang.Object
- 
- org.apache.coyote.Request
 
- 
 public final class Request extends java.lang.ObjectThis 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. 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 SummaryConstructors Constructor Description Request()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaction(ActionCode actionCode, java.lang.Object param)voidaddPathParameter(java.lang.String name, java.lang.String value)voidclearRequestThread()MessageBytescontentType()MessageBytesdecodedURI()intdoRead(ApplicationBufferHandler handler)Read data from the input buffer and put it into ApplicationBufferHandler.java.lang.ObjectgetAttribute(java.lang.String name)java.util.HashMap<java.lang.String,java.lang.Object>getAttributes()MessageBytesgetAuthType()intgetAvailable()longgetBytesRead()java.lang.StringgetCharacterEncoding()Get the character encoding used for this request.java.nio.charset.CharsetgetCharset()Get the character encoding used for this request.intgetContentLength()longgetContentLengthLong()java.lang.StringgetContentType()ServerCookiesgetCookies()java.lang.ExceptiongetErrorException()Get the Exception that occurred during the writing of the response.java.lang.StringgetHeader(java.lang.String name)InputBuffergetInputBuffer()intgetLocalPort()MimeHeadersgetMimeHeaders()java.lang.ObjectgetNote(int pos)ParametersgetParameters()java.lang.StringgetPathParameter(java.lang.String name)ReadListenergetReadListener()intgetRemotePort()MessageBytesgetRemoteUser()booleangetRemoteUserNeedsAuthorization()RequestInfogetRequestProcessor()ResponsegetResponse()booleangetSendfile()intgetServerPort()longgetStartTime()booleangetSupportsRelativeRedirects()longgetThreadId()java.util.Map<java.lang.String,java.lang.String>getTrailerFields()UDecodergetURLDecoder()booleanhasExpectation()booleanisExceptionPresent()booleanisFinished()booleanisProcessing()booleanisReady()booleanisRequestThread()booleanisTrailerFieldsReady()MessageByteslocalAddr()MessageByteslocalName()MessageBytesmethod()voidonDataAvailable()MessageBytespeerAddr()MessageBytesprotocol()MessageBytesqueryString()voidrecycle()MessageBytesremoteAddr()MessageBytesremoteHost()MessageBytesrequestURI()MessageBytesscheme()booleansendAllDataReadEvent()MessageBytesserverName()Get the "virtual host", derived from the Host: header associated with this request.voidsetAttribute(java.lang.String name, java.lang.Object o)voidsetAvailable(int available)voidsetCharset(java.nio.charset.Charset charset)voidsetContentLength(long len)voidsetContentType(java.lang.String type)voidsetContentType(MessageBytes mb)voidsetErrorException(java.lang.Exception ex)Set the error Exception that occurred during the writing of the response processing.voidsetExpectation(boolean expectation)protected voidsetHook(ActionHook hook)voidsetInputBuffer(InputBuffer inputBuffer)voidsetLocalPort(int port)voidsetNote(int pos, java.lang.Object value)Used to store private data.voidsetReadListener(ReadListener listener)voidsetRemotePort(int port)voidsetRemoteUserNeedsAuthorization(boolean remoteUserNeedsAuthorization)voidsetRequestThread()voidsetResponse(Response response)voidsetSendfile(boolean sendfile)voidsetServerPort(int serverPort)voidsetStartTime(long startTime)java.lang.StringtoString()voidupdateCounters()
 
- 
- 
- 
Method Detail- 
getReadListenerpublic ReadListener getReadListener() 
 - 
setReadListenerpublic void setReadListener(ReadListener listener) 
 - 
isReadypublic boolean isReady() 
 - 
onDataAvailablepublic void onDataAvailable() throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
sendAllDataReadEventpublic boolean sendAllDataReadEvent() 
 - 
getMimeHeaderspublic MimeHeaders getMimeHeaders() 
 - 
isTrailerFieldsReadypublic boolean isTrailerFieldsReady() 
 - 
getTrailerFieldspublic java.util.Map<java.lang.String,java.lang.String> getTrailerFields() 
 - 
getURLDecoderpublic UDecoder getURLDecoder() 
 - 
schemepublic MessageBytes scheme() 
 - 
methodpublic MessageBytes method() 
 - 
requestURIpublic MessageBytes requestURI() 
 - 
decodedURIpublic MessageBytes decodedURI() 
 - 
queryStringpublic MessageBytes queryString() 
 - 
protocolpublic MessageBytes protocol() 
 - 
serverNamepublic MessageBytes serverName() Get the "virtual host", derived from the Host: header associated with this request.- Returns:
- The buffer holding the server name, if any. Use isNull() to check if there is no value set.
 
 - 
getServerPortpublic int getServerPort() 
 - 
setServerPortpublic void setServerPort(int serverPort) 
 - 
remoteAddrpublic MessageBytes remoteAddr() 
 - 
peerAddrpublic MessageBytes peerAddr() 
 - 
remoteHostpublic MessageBytes remoteHost() 
 - 
localNamepublic MessageBytes localName() 
 - 
localAddrpublic MessageBytes localAddr() 
 - 
getRemotePortpublic int getRemotePort() 
 - 
setRemotePortpublic void setRemotePort(int port) 
 - 
getLocalPortpublic int getLocalPort() 
 - 
setLocalPortpublic void setLocalPort(int port) 
 - 
getCharacterEncodingpublic java.lang.String getCharacterEncoding() Get the character encoding used for this request.- Returns:
- The value set via setCharset(Charset)or if no call has been made to that method try to obtain if from the content type.
 
 - 
getCharsetpublic java.nio.charset.Charset getCharset() throws java.io.UnsupportedEncodingExceptionGet the character encoding used for this request.- Returns:
- The value set via setCharset(Charset)or if no call has been made to that method try to obtain if from the content type.
- Throws:
- java.io.UnsupportedEncodingException- If the user agent has specified an invalid character encoding
 
 - 
setCharsetpublic void setCharset(java.nio.charset.Charset charset) 
 - 
setContentLengthpublic void setContentLength(long len) 
 - 
getContentLengthpublic int getContentLength() 
 - 
getContentLengthLongpublic long getContentLengthLong() 
 - 
getContentTypepublic java.lang.String getContentType() 
 - 
setContentTypepublic void setContentType(java.lang.String type) 
 - 
contentTypepublic MessageBytes contentType() 
 - 
setContentTypepublic void setContentType(MessageBytes mb) 
 - 
getHeaderpublic java.lang.String getHeader(java.lang.String name) 
 - 
setExpectationpublic void setExpectation(boolean expectation) 
 - 
hasExpectationpublic boolean hasExpectation() 
 - 
getResponsepublic Response getResponse() 
 - 
setResponsepublic void setResponse(Response response) 
 - 
setHookprotected void setHook(ActionHook hook) 
 - 
actionpublic void action(ActionCode actionCode, java.lang.Object param) 
 - 
getCookiespublic ServerCookies getCookies() 
 - 
getParameterspublic Parameters getParameters() 
 - 
addPathParameterpublic void addPathParameter(java.lang.String name, java.lang.String value)
 - 
getPathParameterpublic java.lang.String getPathParameter(java.lang.String name) 
 - 
setAttributepublic void setAttribute(java.lang.String name, java.lang.Object o)
 - 
getAttributespublic java.util.HashMap<java.lang.String,java.lang.Object> getAttributes() 
 - 
getAttributepublic java.lang.Object getAttribute(java.lang.String name) 
 - 
getRemoteUserpublic MessageBytes getRemoteUser() 
 - 
getRemoteUserNeedsAuthorizationpublic boolean getRemoteUserNeedsAuthorization() 
 - 
setRemoteUserNeedsAuthorizationpublic void setRemoteUserNeedsAuthorization(boolean remoteUserNeedsAuthorization) 
 - 
getAuthTypepublic MessageBytes getAuthType() 
 - 
getAvailablepublic int getAvailable() 
 - 
setAvailablepublic void setAvailable(int available) 
 - 
getSendfilepublic boolean getSendfile() 
 - 
setSendfilepublic void setSendfile(boolean sendfile) 
 - 
isFinishedpublic boolean isFinished() 
 - 
getSupportsRelativeRedirectspublic boolean getSupportsRelativeRedirects() 
 - 
getInputBufferpublic InputBuffer getInputBuffer() 
 - 
setInputBufferpublic void setInputBuffer(InputBuffer inputBuffer) 
 - 
doReadpublic int doRead(ApplicationBufferHandler handler) throws java.io.IOException Read data from the input buffer and put it into ApplicationBufferHandler. 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.- Parameters:
- handler- The destination to which to copy the data
- Returns:
- The number of bytes copied
- Throws:
- java.io.IOException- If an I/O error occurs during the copy
 
 - 
setErrorExceptionpublic void setErrorException(java.lang.Exception ex) Set the error Exception that occurred during the writing of the response processing.- Parameters:
- ex- The exception that occurred
 
 - 
getErrorExceptionpublic java.lang.Exception getErrorException() Get the Exception that occurred during the writing of the response.- Returns:
- The exception that occurred
 
 - 
isExceptionPresentpublic boolean isExceptionPresent() 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
getStartTimepublic long getStartTime() 
 - 
setStartTimepublic void setStartTime(long startTime) 
 - 
getThreadIdpublic long getThreadId() 
 - 
clearRequestThreadpublic void clearRequestThread() 
 - 
setRequestThreadpublic void setRequestThread() 
 - 
isRequestThreadpublic boolean isRequestThread() 
 - 
setNotepublic void setNote(int pos, java.lang.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 an array access, may be faster than ThreadLocal for very frequent operations. Example use: 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.- Parameters:
- pos- Index to use to store the note
- value- The value to store at that index
 
 - 
getNotepublic java.lang.Object getNote(int pos) 
 - 
recyclepublic void recycle() 
 - 
updateCounterspublic void updateCounters() 
 - 
getRequestProcessorpublic RequestInfo getRequestProcessor() 
 - 
getBytesReadpublic long getBytesRead() 
 - 
isProcessingpublic boolean isProcessing() 
 
- 
 
-