HTTP Request. This class manages the headers, trailers and content streams of a HTTP request. It
can be used for receiving or generating requests.
This class is not synchronized. It should be explicitly synchronized if it is used by multiple
threads.
__CONNECT
public static final String __CONNECT
Request METHODS.
__DELETE
public static final String __DELETE
Request METHODS.
__GET
public static final String __GET
Request METHODS.
__HEAD
public static final String __HEAD
Request METHODS.
__MOVE
public static final String __MOVE
Request METHODS.
__OPTIONS
public static final String __OPTIONS
Request METHODS.
__POST
public static final String __POST
Request METHODS.
__PUT
public static final String __PUT
Request METHODS.
__TRACE
public static final String __TRACE
Request METHODS.
__maxFormContentSize
public static int __maxFormContentSize
Max size of the form content. Limits the size of the data a client can push at the server.
Set via the org.mortbay.http.HttpRequest.maxContentSize system property.
__maxLineLength
public static int __maxLineLength
Maximum header line length.
__methodCache
public static final StringMap __methodCache
__versionCache
public static final StringMap __versionCache
destroy
public void destroy()
Destroy the request. Help the garbage collector by null everything that we can.
- destroy in interface HttpMessage
getAcceptableTransferCodings
public List getAcceptableTransferCodings()
Get the acceptable transfer encodings. The TE field is used to construct a list of acceptable
extension transfer codings in quality order. An empty list implies that only "chunked" is
acceptable. A null list implies that no transfer coding can be applied.
If the "trailer" coding is found in the TE field, then message trailers are enabled in any
linked response.
getAuthType
public String getAuthType()
getAuthUser
public String getAuthUser()
getCookies
public Cookie[] getCookies()
Extract received cookies from a header.
getEncodedPath
public String getEncodedPath()
Get the encoded request path.
- The path with % encoding.
getHost
public String getHost()
Get the request host.
- The host name obtained from an absolute URI, the HTTP header field, the requests
connection or the local host name.
getHttpResponse
public HttpResponse getHttpResponse()
Get the HTTP Response. Get the HTTP Response associated with this request.
getMethod
public String getMethod()
Get the HTTP method for this request. Returns the method with which the request was made. The
returned value can be "GET", "HEAD", "POST", or an extension method. Same as the CGI variable
REQUEST_METHOD.
getParameter
public String getParameter(String name)
Get a parameter value.
getParameterNames
public Set getParameterNames()
Get the set of parameter names.
getParameterStringArrayMap
public Map getParameterStringArrayMap()
- Parameters as a map of String arrays
getParameterValues
public List getParameterValues(String name)
Get multi valued paramater.
getParameters
public MultiMap getParameters()
getPath
public String getPath()
Get the request path.
- The URI path of the request.
getPort
public int getPort()
Get the request port. The port is obtained either from an absolute URI, the HTTP Host header
field, the connection or the default.
- The port. 0 should be interpreted as the default port.
getQuery
public String getQuery()
Get the request query.
- the request query excluding the '?'
getRemoteAddr
public String getRemoteAddr()
getRemoteHost
public String getRemoteHost()
getRequestLine
public String getRequestLine()
Return the HTTP request line as it was received.
getRequestURL
public StringBuffer getRequestURL()
Reconstructs the URL the client used to make the request. The returned URL contains a
protocol, server name, port number, and server path, but it does not include query string
parameters.
Because this method returns a
StringBuffer
, not a string, you can modify the
URL easily, for example, to append query parameters.
This method is useful for creating redirect messages and for reporting errors.
- a
StringBuffer
object containing the reconstructed URL
getResponse
public HttpResponse getResponse()
use getHttpResponse()
getRootURL
public StringBuffer getRootURL()
Reconstructs the URL the client used to make the request. The returned URL contains a
protocol, server name, port number, and, but it does not include a path.
Because this method returns a
StringBuffer
, not a string, you can modify the
URL easily, for example, to append path and query parameters.
This method is useful for creating redirect messages and for reporting errors.
getScheme
public String getScheme()
Get the request Scheme. The scheme is obtained from an absolute URI. If the URI in the
request is not absolute, then the connections default scheme is returned. If there is no
connection "http" is returned.
- The request scheme (eg. "http", "https", etc.)
getTimeStamp
public long getTimeStamp()
Get Request TimeStamp
- The time that the request was received.
getTimeStampStr
public String getTimeStampStr()
Get Request TimeStamp
- The time that the request was received.
getURI
public URI getURI()
Get the full URI.
- the request URI (not a clone).
getUserPrincipal
public Principal getUserPrincipal()
hasUserPrincipal
public boolean hasUserPrincipal()
isConfidential
public boolean isConfidential()
- True if this request came over an confidential channel such as SSL.
isHandled
public boolean isHandled()
Is the request handled.
- True if the request has been set to handled or the associated response is not
editable.
isIntegral
public boolean isIntegral()
- True if this request came over an integral channel such as SSL
isUserInRole
public boolean isUserInRole(String role)
readHeader
public void readHeader(LineInput in)
throws IOException
Read the request line and header.
setAuthType
public void setAuthType(String a)
setAuthUser
public void setAuthUser(String user)
setHandled
public void setHandled(boolean handled)
Set the handled status.
setMethod
public void setMethod(String method)
setPath
public void setPath(String path)
setQuery
public void setQuery(String q)
setTimeStamp
public void setTimeStamp(long ts)
setUserPrincipal
public void setUserPrincipal(Principal principal)
writeHeader
public void writeHeader(Writer writer)
throws IOException
Write the request header. Places the message in __MSG_SENDING state.
writer
- Http output stream
writeRequestLine
public void writeRequestLine(Writer writer)
throws IOException
Write the HTTP request line as it was received.