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 [[email protected]], James Todd [[email protected]], Jason Hunter [[email protected]], Harish Prabandham, Alex Cruikshank [[email protected]], Hans Bergsten [[email protected]], Costin Manolache, Remy Maucherat
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
action
(ActionCode actionCode, Object param) void
addPathParameter
(String name, String value) void
int
doRead
(ApplicationBufferHandler handler) Read data from the input buffer and put it into ApplicationBufferHandler.getAttribute
(String name) int
long
Get the character encoding used for this request.Get the character encoding used for this request.int
long
Get the Exception that occurred during the writing of the response.int
getNote
(int pos) getPathParameter
(String name) int
boolean
boolean
int
long
boolean
long
boolean
boolean
boolean
boolean
boolean
isReady()
boolean
boolean
method()
void
peerAddr()
protocol()
void
recycle()
scheme()
boolean
Get the "virtual host", derived from the Host: header associated with this request.void
setAttribute
(String name, Object o) void
setAvailable
(int available) void
setCharset
(Charset charset) void
setContentLength
(long len) void
setContentType
(String type) void
void
Set the error Exception that occurred during the writing of the response processing.void
setExpectation
(boolean expectation) protected void
setHook
(ActionHook hook) void
setInputBuffer
(InputBuffer inputBuffer) void
setLocalPort
(int port) void
Used to store private data.void
setReadListener
(ReadListener listener) void
setRemotePort
(int port) void
setRemoteUserNeedsAuthorization
(boolean remoteUserNeedsAuthorization) void
void
setResponse
(Response response) void
setSendfile
(boolean sendfile) void
setServerPort
(int serverPort) void
setStartTime
(long startTime) toString()
void
-
Constructor Details
-
Request
public Request()
-
-
Method Details
-
getReadListener
-
setReadListener
-
isReady
public boolean isReady() -
onDataAvailable
- Throws:
IOException
-
sendAllDataReadEvent
public boolean sendAllDataReadEvent() -
getMimeHeaders
-
isTrailerFieldsReady
public boolean isTrailerFieldsReady() -
getTrailerFields
-
getMimeTrailerFields
-
getURLDecoder
-
scheme
-
method
-
requestURI
-
decodedURI
-
queryString
-
protocol
-
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.
-
getServerPort
public int getServerPort() -
setServerPort
public void setServerPort(int serverPort) -
remoteAddr
-
peerAddr
-
remoteHost
-
localName
-
localAddr
-
getRemotePort
public int getRemotePort() -
setRemotePort
public void setRemotePort(int port) -
getLocalPort
public int getLocalPort() -
setLocalPort
public void setLocalPort(int port) -
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.
-
getCharset
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. - Throws:
UnsupportedEncodingException
- If the user agent has specified an invalid character encoding
-
setCharset
-
setContentLength
public void setContentLength(long len) -
getContentLength
public int getContentLength() -
getContentLengthLong
public long getContentLengthLong() -
getContentType
-
setContentType
-
contentType
-
setContentType
-
getHeader
-
setExpectation
public void setExpectation(boolean expectation) -
hasExpectation
public boolean hasExpectation() -
getResponse
-
setResponse
-
setHook
-
action
-
getCookies
-
getParameters
-
addPathParameter
-
getPathParameter
-
setAttribute
-
getAttributes
-
getAttribute
-
getRemoteUser
-
getRemoteUserNeedsAuthorization
public boolean getRemoteUserNeedsAuthorization() -
setRemoteUserNeedsAuthorization
public void setRemoteUserNeedsAuthorization(boolean remoteUserNeedsAuthorization) -
getAuthType
-
getAvailable
public int getAvailable() -
setAvailable
public void setAvailable(int available) -
getSendfile
public boolean getSendfile() -
setSendfile
public void setSendfile(boolean sendfile) -
isFinished
public boolean isFinished() -
getSupportsRelativeRedirects
public boolean getSupportsRelativeRedirects() -
getInputBuffer
-
setInputBuffer
-
doRead
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:
IOException
- If an I/O error occurs during the copy
-
setErrorException
Set the error Exception that occurred during the writing of the response processing.- Parameters:
ex
- The exception that occurred
-
getErrorException
Get the Exception that occurred during the writing of the response.- Returns:
- The exception that occurred
-
isExceptionPresent
public boolean isExceptionPresent() -
toString
-
getStartTime
public long getStartTime() -
setStartTime
public void setStartTime(long startTime) -
getThreadId
public long getThreadId() -
clearRequestThread
public void clearRequestThread() -
setRequestThread
public void setRequestThread() -
isRequestThread
public boolean isRequestThread() -
setNote
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 notevalue
- The value to store at that index
-
getNote
-
recycle
public void recycle() -
updateCounters
public void updateCounters() -
getRequestProcessor
-
getBytesRead
public long getBytesRead() -
isProcessing
public boolean isProcessing()
-