Package org.apache.coyote
Class Request
java.lang.Object
org.apache.coyote.Request
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. 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
- 
Method SummaryModifier and TypeMethodDescriptionvoidaction(ActionCode actionCode, Object param) voidaddPathParameter(String name, String value) voidintdoRead(ApplicationBufferHandler handler) Read data from the input buffer and put it into ApplicationBufferHandler.getAttribute(String name) intlongGet the character encoding used for this request.Get the character encoding used for this request.intlongGet the Exception that occurred during the writing of the response.intgetNote(int pos) getPathParameter(String name) intbooleanbooleanintlonglongbooleanlongbooleanbooleanbooleanbooleanbooleanisReady()booleanbooleanmethod()voidpeerAddr()protocol()voidrecycle()scheme()booleanGet the "virtual host", derived from the Host: header associated with this request.voidsetAttribute(String name, Object o) voidsetAvailable(int available) voidsetCharset(Charset charset) voidsetContentLength(long len) voidsetContentType(String type) voidvoidSet 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) voidUsed to store private data.voidsetReadListener(ReadListener listener) voidsetRemotePort(int port) voidsetRemoteUserNeedsAuthorization(boolean remoteUserNeedsAuthorization) voidvoidsetResponse(Response response) voidsetSendfile(boolean sendfile) voidsetServerPort(int serverPort) voidsetStartTime(long startTime) Deprecated.This setter will be removed in Tomcat 11voidsetStartTimeNanos(long startTimeNanos) toString()void
- 
Constructor Details- 
Requestpublic Request()
 
- 
- 
Method Details- 
getReadListener
- 
setReadListener
- 
isReadypublic boolean isReady()
- 
onDataAvailable- Throws:
- IOException
 
- 
sendAllDataReadEventpublic boolean sendAllDataReadEvent()
- 
getMimeHeaders
- 
isTrailerFieldsReadypublic boolean isTrailerFieldsReady()
- 
getTrailerFields
- 
getURLDecoder
- 
scheme
- 
method
- 
requestURI
- 
decodedURI
- 
queryString
- 
protocol
- 
serverNameGet 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) 
- 
remoteAddr
- 
peerAddr
- 
remoteHost
- 
localName
- 
localAddr
- 
getRemotePortpublic int getRemotePort()
- 
setRemotePortpublic void setRemotePort(int port) 
- 
getLocalPortpublic int getLocalPort()
- 
setLocalPortpublic void setLocalPort(int port) 
- 
getCharacterEncodingGet 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.
 
- 
getCharsetGet 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:
- UnsupportedEncodingException- If the user agent has specified an invalid character encoding
 
- 
setCharset
- 
setContentLengthpublic void setContentLength(long len) 
- 
getContentLengthpublic int getContentLength()
- 
getContentLengthLongpublic long getContentLengthLong()
- 
getContentType
- 
setContentType
- 
contentType
- 
setContentType
- 
getHeader
- 
setExpectationpublic void setExpectation(boolean expectation) 
- 
hasExpectationpublic boolean hasExpectation()
- 
getResponse
- 
setResponse
- 
setHook
- 
action
- 
getCookies
- 
getParameters
- 
addPathParameter
- 
getPathParameter
- 
setAttribute
- 
getAttributes
- 
getAttribute
- 
getRemoteUser
- 
getRemoteUserNeedsAuthorizationpublic boolean getRemoteUserNeedsAuthorization()
- 
setRemoteUserNeedsAuthorizationpublic void setRemoteUserNeedsAuthorization(boolean remoteUserNeedsAuthorization) 
- 
getAuthType
- 
getAvailablepublic int getAvailable()
- 
setAvailablepublic void setAvailable(int available) 
- 
getSendfilepublic boolean getSendfile()
- 
setSendfilepublic void setSendfile(boolean sendfile) 
- 
isFinishedpublic boolean isFinished()
- 
getSupportsRelativeRedirectspublic boolean getSupportsRelativeRedirects()
- 
getInputBuffer
- 
setInputBuffer
- 
doReadRead 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:
- IOException- If an I/O error occurs during the copy
 
- 
setErrorExceptionSet the error Exception that occurred during the writing of the response processing.- Parameters:
- ex- The exception that occurred
 
- 
getErrorExceptionGet the Exception that occurred during the writing of the response.- Returns:
- The exception that occurred
 
- 
isExceptionPresentpublic boolean isExceptionPresent()
- 
getRequestId
- 
getProtocolRequestId
- 
getServletConnection
- 
toString
- 
getStartTimepublic long getStartTime()
- 
setStartTimeDeprecated.This setter will be removed in Tomcat 11- Parameters:
- startTime- time
 
- 
getStartTimeNanospublic long getStartTimeNanos()
- 
setStartTimeNanospublic void setStartTimeNanos(long startTimeNanos) 
- 
getThreadIdpublic long getThreadId()
- 
clearRequestThreadpublic void clearRequestThread()
- 
setRequestThreadpublic void setRequestThread()
- 
isRequestThreadpublic boolean isRequestThread()
- 
setNoteUsed 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
 
- 
getNote
- 
recyclepublic void recycle()
- 
updateCounterspublic void updateCounters()
- 
getRequestProcessor
- 
getBytesReadpublic long getBytesRead()
- 
isProcessingpublic boolean isProcessing()
 
-