|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.mortbay.HTTP.HttpHeader | +--com.mortbay.HTTP.HttpRequest
A received HTTP request. Implements and extends the javax.servlet.http.HttpServletRequest interface. The extensions are for HttpHandler instances that need to modify the request or have better access to the IO.
http://localhost:1234/Servlet/Path/Foo/Bar?aaa=123&bbb=456
HttpServer
Field Summary | |
static byte[] |
Continue
|
static java.lang.String |
DELETE
|
static java.lang.String |
GET
|
static java.lang.String |
HEAD
|
static java.lang.String |
MOVE
|
static java.lang.String |
OPTIONS
|
static java.lang.String |
POST
|
static java.lang.String |
PUT
|
static java.lang.String |
SESSIONID_COOKIE
|
static java.lang.String |
SESSIONID_NONE
|
static java.lang.String |
SESSIONID_NOT_CHECKED
For decoding session ids etc. |
static java.lang.String |
SESSIONID_URL
|
Fields inherited from class com.mortbay.HTTP.HttpHeader |
__COLON,
__CRLF,
__dateReceive,
__dateSend,
__singleValuedMap,
Authorization,
Chunked,
Close,
COLON,
Connection,
ContentLength,
ContentType,
Cookie,
CRLF,
Date,
Expires,
Host,
HTTP_1_0,
HTTP_1_1,
IfModifiedSince,
IfUnmodifiedSince,
LastModified,
Referer,
SetCookie,
SingleValued,
TransferEncoding,
UserAgent,
WwwAuthenticate,
WwwFormUrlEncode |
Constructor Summary | |
HttpRequest(HttpServer httpServer,
java.net.Socket connection,
InetAddrPort address)
Construct received request. |
|
HttpRequest(HttpServer server,
java.lang.String method,
java.lang.String uri)
Construct request to send |
|
HttpRequest(HttpServer server,
java.lang.String method,
URI uri)
Construct request to send |
Method Summary | |
void |
cookiesAsParameters()
Decode Cookies If includeAsParameters is true, cookies may be fetch via the getParameter() method |
void |
decodeFormParameters()
decode Form Parameters After this call, form parameters may be fetch via the getParameter() method. |
void |
destroy()
Destroy the request. |
java.lang.Object |
getAttribute(java.lang.String name)
Returns the value of the named attribute as an Object . |
java.util.Enumeration |
getAttributeNames()
Returns an Enumeration containing the
names of the attributes available to this request. |
java.lang.String |
getAuthType()
Get the authentication method (normally BASIC) |
java.lang.String |
getCharacterEncoding()
Returns the character set encoding for the input of this request. |
int |
getContentLength()
Get the length of any content in this request or -1 if not known. |
java.lang.String |
getContentType()
Return the MIME encoding type of any (form) content in this request or null if not known. |
javax.servlet.http.Cookie[] |
getCookies()
Returns an array containing all of the Cookie
objects the browser sent with this request. |
HttpInputStream |
getHttpInputStream()
Get the HttpInputStream of the request. |
HttpResponse |
getHttpResponse()
Get associated response |
HttpServer |
getHttpServer()
Get the HttpServer of the request. |
javax.servlet.ServletInputStream |
getInputStream()
Get request input stream |
java.lang.String |
getMethod()
Get the HTTP method for this request. |
java.lang.String |
getParameter(java.lang.String name)
Deprecated. use getParameterValues |
java.util.Enumeration |
getParameterNames()
Returns an enumeration of strings representing the parameter names for this request. |
java.lang.String[] |
getParameterValues(java.lang.String name)
Returns the multi-values of the specified parameter for the request. |
java.lang.String |
getPathInfo()
Get the URI segment that is more than the servlet path |
java.lang.String |
getPathTranslated()
Return the actual URI after translation. |
java.lang.String |
getProtocol()
Get the actual protocol and version. |
java.lang.String |
getQueryString()
Get the query string of the request |
java.io.BufferedReader |
getReader()
Returns the body of the request as a BufferedReader
that translates character set encodings. |
java.lang.String |
getRealPath(java.lang.String path)
Deprecated. |
java.lang.String |
getRemoteAddr()
Get the remote IP address of the system that sent the request. |
java.lang.String |
getRemoteHost()
Get the hostname of the system that sent the request. |
java.lang.String |
getRemoteUser()
Get the remote user name decoded from authentication headers |
java.lang.String |
getRequestedSessionId()
Returns the session ID specified by the client. |
java.lang.String |
getRequestLine()
Return the HTTP request line as it was received |
java.lang.String |
getRequestPath()
Get the URI path minus any query strings with translations applied. |
java.lang.String |
getRequestURI()
Get the full URI. |
java.lang.String |
getResourcePath()
Get the resource path. |
java.lang.String |
getScheme()
Returns the scheme of the URL used in this request, for example "http", "https" |
java.lang.String |
getServerName()
Get the host name of the server that received the request. |
int |
getServerPort()
Get the port number used in the request |
java.lang.String |
getServletPath()
Get the URI sub path that matched to the servlet. |
javax.servlet.http.HttpSession |
getSession()
Returns the current session associated with this request, or if the request does not have a session, creates one. |
javax.servlet.http.HttpSession |
getSession(boolean create)
Returns the current HttpSession
associated with this request or, if necessary, creates
a new session for the request. |
java.lang.String |
getVersion()
Get the protocol version |
java.io.InputStream |
handleRequestLocally()
Handle a request locally. |
boolean |
isLocalRequest()
Get local request status |
boolean |
isRequestedSessionIdFromCookie()
Checks whether the session ID this request submitted came in as a cookie, rather than from the getSession()
method. |
boolean |
isRequestedSessionIdFromUrl()
Deprecated. |
boolean |
isRequestedSessionIdFromURL()
Checks whether the session ID this request submitted came in as part of the request URL, rather than from the getSession() method. |
boolean |
isRequestedSessionIdValid()
Checks whether this request has a valid session in the current session context (which is a HttpSessionContext ). |
void |
putParameter(java.lang.String name,
java.lang.String value)
Put a parameter into the request. |
void |
putParameterValues(java.lang.String name,
java.lang.String[] values)
Put a multi-valued parameter into the request. |
void |
setAttribute(java.lang.String name,
java.lang.Object o)
Stores an attribute in the context of this request. |
void |
setHttpResponse(HttpResponse response)
Set associated response |
void |
setPathTranslated(java.lang.String pathTranslated)
Set the translated path |
void |
setRemoteUser(java.lang.String authType,
java.lang.String name)
Set the remoteUser from authentication headers |
void |
setRequestPath(java.lang.String path)
Set the URI path and redirect params |
void |
setResourcePath(java.lang.String path)
Set the resource path. |
void |
setResourcePath(URI newuri)
Set the resource path. |
void |
setScheme(java.lang.String scheme)
Sets the scheme of the URL used in this request, for example "http", "https" |
void |
setServletPath(java.lang.String servletPath)
Set the servlet path getServletPath and getPathInfo are not valid until this has been called. |
static void |
setSessionMaxInactiveInterval(int defaultTime)
Set the default session timeout. |
void |
setVersion(java.lang.String version)
Set the request version |
void |
translateAddress(java.lang.String pathSpec,
java.lang.String newPath,
boolean translateURI)
Translate the URI Apply any translation rules to the URI. |
void |
write(java.io.OutputStream outstream)
Write the request header to an output stream |
Methods inherited from class com.mortbay.HTTP.HttpHeader |
dump,
getDateHeader,
getHeader,
getHeaderNames,
getIntHeader,
read,
setDateHeader,
setHeader,
setIntHeader,
toString,
write,
write |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String GET
public static final java.lang.String POST
public static final java.lang.String PUT
public static final java.lang.String HEAD
public static final java.lang.String DELETE
public static final java.lang.String MOVE
public static final java.lang.String OPTIONS
public static final byte[] Continue
public static final java.lang.String SESSIONID_NOT_CHECKED
public static final java.lang.String SESSIONID_URL
public static final java.lang.String SESSIONID_COOKIE
public static final java.lang.String SESSIONID_NONE
Constructor Detail |
public HttpRequest(HttpServer httpServer, java.net.Socket connection, InetAddrPort address) throws java.io.IOException
httpServer
- The server for this request.connection
- The socket the request was received over.address
- the IP address that was listened on for the request.public HttpRequest(HttpServer server, java.lang.String method, java.lang.String uri)
httpServer
- The server for this request.method
- The method for this requesturi
- The uri for this request.public HttpRequest(HttpServer server, java.lang.String method, URI uri)
httpServer
- The server for this request.method
- The method for this requesturi
- The uri for this request.Method Detail |
public boolean isLocalRequest()
public void setHttpResponse(HttpResponse response)
public HttpResponse getHttpResponse()
public java.lang.String getRequestPath()
/Servlet/Path/Foo/Bar
public void setRequestPath(java.lang.String path)
public java.lang.String getResourcePath()
public void setResourcePath(java.lang.String path)
path
- public void setResourcePath(URI newuri)
path
- public java.lang.String getRequestLine()
public java.lang.String getVersion()
public void setPathTranslated(java.lang.String pathTranslated)
pathTranslated
- Translated Path.public void setServletPath(java.lang.String servletPath) throws java.net.MalformedURLException
public void setVersion(java.lang.String version)
version
- public void translateAddress(java.lang.String pathSpec, java.lang.String newPath, boolean translateURI)
pathSpec
- The path segment to be translated. This may end
with the special characters defined in PathMap.newPath
- The path segment to replace path with.translateURI
- If true, the URI of the request is translated,
otherwise only the resource path is affected.public void setRemoteUser(java.lang.String authType, java.lang.String name)
public void decodeFormParameters() throws java.io.IOException
public void cookiesAsParameters() throws java.io.IOException
public void write(java.io.OutputStream outstream) throws java.io.IOException
public void putParameter(java.lang.String name, java.lang.String value)
deprecated
- Use putParameterValuespublic void putParameterValues(java.lang.String name, java.lang.String[] values)
public HttpServer getHttpServer()
public HttpInputStream getHttpInputStream()
public java.io.InputStream handleRequestLocally() throws java.io.IOException
public int getContentLength()
-1
public java.lang.String getContentType()
null
public java.lang.String getProtocol()
HTTP/1.0
public java.lang.String getServerName()
localhost
public int getServerPort()
1234
public java.lang.String getRemoteAddr()
127.0.0.1
public java.lang.String getRemoteHost()
localhost
public java.lang.String getRealPath(java.lang.String path)
path
- the path to be translatedpublic javax.servlet.ServletInputStream getInputStream()
public java.lang.String getParameter(java.lang.String name)
name
- the parameter namepublic java.lang.String[] getParameterValues(java.lang.String name)
name
- a String
containing the name of
the parameter whose value is requestedString
objects
containing the parameter's valuesServletRequest.getParameter(java.lang.String)
public java.util.Enumeration getParameterNames()
Enumeration
of String
objects, each String
containing
the name of a request parameter; or an
empty Enumeration
if the
request has no parameterspublic java.lang.String getScheme()
String
containing the name
of the scheme used to make this requestpublic void setScheme(java.lang.String scheme)
public java.lang.Object getAttribute(java.lang.String name)
Object
.
This method allows the servlet engine to give the servlet
custom information about a request. This method returns
null
if no attribute of the given name exists.
Attribute names should follow the same conventions as package
names. This specification reserves names matching java.*
,
javax.*
, and sun.*
.
name
- the attribute namepublic java.util.Enumeration getAttributeNames()
Enumeration
containing the
names of the attributes available to this request.
This method returns an empty Enumeration
if the request has no attributes available to it.Enumeration
of strings
containing the names
of the request's attributespublic void setAttribute(java.lang.String name, java.lang.Object o)
Attribute names should follow the same conventions as
package names. Names beginning with java.*
,
javax.*
, and com.sun.*
, are
reserved for use by Sun Microsystems.
key
- a String
specifying
the name of the attributeo
- an Object
containing
the context of the requestpublic java.lang.String getCharacterEncoding()
public java.lang.String getMethod()
GET
public java.lang.String getRequestURI()
/Servlet/Path/Foo/BarIf the browser uses the abs_path URI, if it uses absoulteURI it will return
http://localhost:1234/Servlet/Path/Foo/Bar
public java.lang.String getServletPath()
/Servlet/Path
public java.lang.String getPathInfo()
/Foo/Bar
public java.lang.String getPathTranslated()
null
public java.lang.String getQueryString()
aaa=123&bbb=456
public java.lang.String getRemoteUser()
null
public java.lang.String getAuthType()
null
public javax.servlet.http.Cookie[] getCookies()
Cookie
objects the browser sent with this request.
This method returns null
if the browser did
not send any cookies.Cookies
included with this request, or null
if the request has no cookiespublic java.lang.String getRequestedSessionId()
null
.String
specifying the session
ID, or null
if the request did
not specify a session IDHttpServletRequest.isRequestedSessionIdValid()
public javax.servlet.http.HttpSession getSession()
HttpSession
associated
with this requestpublic javax.servlet.http.HttpSession getSession(boolean create)
HttpSession
associated with this request or, if necessary, creates
a new session for the request. Use true
for create
to create a new session,
or false
to return the current
HttpSession
.
If create
is false
and the request has no valid HttpSession
,
this method returns null
.
To make sure the session is properly maintained,
you must call this method at least once before
you write any output to the response. Newly created
sessions (that is, sessions for which
HttpSession.isNew
returns true
)
do not have any application-specific state.
true
- to create
a new session for this request;
false
to return the current
sessionHttpSession
associated
with this request or null
if
create
is false
and the request has no valid sessionpublic boolean isRequestedSessionIdFromCookie()
HttpServletRequest.getSession(boolean)
method.true
if the session ID
came in as a
cookie; otherwise, false
HttpServletRequest.getSession(boolean)
public boolean isRequestedSessionIdFromUrl()
public boolean isRequestedSessionIdFromURL()
HttpServletRequest.getSession(boolean)
method.true
if the session ID
came in as part of an URL; otherwise,
false
HttpServletRequest.getSession(boolean)
public boolean isRequestedSessionIdValid()
HttpSessionContext
).
If the session is not valid,
the HttpServletRequest.getSession(boolean)
method never returns it.true
if this
request has a valid session
in the current session context;
otherwise, false
HttpServletRequest.getRequestedSessionId()
,
HttpServletRequest.getSession(boolean)
,
HttpSessionContext
public java.io.BufferedReader getReader()
BufferedReader
that translates character set encodings.BufferedReader
containing the body of the requestServletRequest.getInputStream()
method
has been called on this requestServletRequest.getInputStream()
public void destroy()
public static void setSessionMaxInactiveInterval(int defaultTime)
default
- The default timeout in seconds
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |