| java.lang.Object com.quadcap.http.server22.HttpRequest
HttpRequest | public class HttpRequest implements HttpServletRequest(Code) | | This class encapsulates the information that makes up a single HTTP
request, including the method, URI, and the headers.
author: Stan Bailes |
Constructor Summary | |
public | HttpRequest(WebWorker w) Using the specified worker's input stream, read an HTTP request,
and construct a new HttpRequest object to represent it. |
Method Summary | |
boolean | badRequest() | final int | compareAccept(String a, String b) | public Object | getAttribute(String name) Returns the value of the named attribute of the request, or
null if the attribute does not exist. | public Enumeration | getAttributeNames() | public String | getAuthType() Gets the authentication scheme of this request. | public String | getCharacterEncoding() Returns the character set encoding for the input of this request. | public int | getContentLength() Returns the size of the request entity data, or -1 if not known. | public String | getContentType() Returns the Internet Media Type of the request entity data, or
null if not known. | public String | getContextPath() | public Cookie[] | getCookies() Gets the array of cookies found in this request. | public long | getDateHeader(String name) Gets the value of the requested date header field of this
request. | public String | getHeader(String name) Gets the value of the requested header field of this request. | public Enumeration | getHeaderNames() | public Enumeration | getHeaders() Gets the header names for this request.
an enumeration of strings representing the header namesfor this request. | public Enumeration | getHeaders(String name) | public ServletInputStream | getInputStream() Returns an input stream for reading binary data in the request body. | public int | getIntHeader(String name) Gets the value of the specified integer header field of this
request. | final float | getLangQual(String s) | public Locale | getLocale() | public Enumeration | getLocales() | public String | getMethod() Gets the HTTP method (for example, GET, POST, PUT) with which
this request was made. | public String | getParameter(String name) Returns a string containing the lone value of the specified
parameter, or null if the parameter does not exist. | public Enumeration | getParameterNames() Returns the parameter names for this request as an enumeration
of strings, or an empty enumeration if there are no parameters
or the input stream is empty. | public String[] | getParameterValues(String name) Returns the values of the specified parameter for the request as
an array of strings, or null if the named parameter does not
exist. | public String | getPathInfo() Gets any optional extra path information following the servlet
path of this request's URI, but immediately preceding its query
string. | public String | getPathTranslated() Gets any optional extra path information following the servlet
path of this request's URI, but immediately preceding its query
string, and translates it to a real path. | public String | getProtocol() Returns the protocol and version of the request as a string of
the form <protocol>/<major version>.<minor
version> . | public String | getQueryString() Gets any query string that is part of the HTTP request URI. | public BufferedReader | getReader() Returns a buffered reader for reading text in the request body.
This translates character set encodings as appropriate. | public String | getRealPath(String path) Applies alias rules to the specified virtual path and returns
the corresponding real path, or null if the translation can not
be performed for any reason. | public String | getRemoteAddr() Returns the IP address of the agent that sent the request. | public String | getRemoteHost() Returns the fully qualified host name of the agent that sent the
request. | public String | getRemoteUser() Gets the name of the user making this request. | public RequestDispatcher | getRequestDispatcher(String path) | public String | getRequestURI() Gets, from the first line of the HTTP request, the part of this
request's URI that is to the left of any query string. | public String | getRequestedSessionId() Gets the session id specified with this request. | public String | getScheme() Returns the scheme of the URL used in this request, for example
"http", "https", or "ftp". | public String | getServerName() Returns the host name of the server that received the request. | public int | getServerPort() Returns the port number on which this request was received. | public String | getServletPath() Gets the part of this request's URI that refers to the servlet
being invoked. | public HttpSession | getSession(boolean create) Gets the current valid session associated with this request, if
create is false or, if necessary, creates a new session for the
request, if create is true. | public HttpSession | getSession() Gets the current valid session associated with this request, and
if necessary, creates a new session for the request. | String | getToken(OctetMap map) | public Principal | getUserPrincipal() Return a Principal object indicating the identity of the user
associated with this request. | public boolean | isRequestedSessionIdFromCookie() Checks whether the session id specified by this request came in
as a cookie. | public boolean | isRequestedSessionIdFromURL() Checks whether the session id specified by this request came in
as part of the URL. | public boolean | isRequestedSessionIdFromUrl() | public boolean | isRequestedSessionIdValid() Checks whether this request is associated with a session that
is valid in the current session context. | public boolean | isSecure() | public boolean | isUserInRole(String role) Returns a boolean indicating whether the authenticated user is
included in the indicated 'role'. | final Locale | makeLocale(String s) | final void | maybeParsePostData() | String | parseHttpVersion() | public static void | parseParameters(Hashtable params, InputStream is) Parse a set of parameters from the specified input stream. | public static void | parseParameters(Hashtable params, Scanner s) | public void | removeAttribute(String name) | public void | reset(HttpInputStream is) Reset the request object and bind it to the input stream. | public void | setAttribute(String name, Object obj) | final void | setRequestDispatcher(HttpDispatcher rd) | void | setResponse(HttpResponse res) Associate this request with its matching response. | public void | setURI(String s) | final static String | urlDecode(String s) |
badRequest | boolean badRequest(Code) | | |
getInputStreamCalled | boolean getInputStreamCalled(Code) | | |
getReaderCalled | boolean getReaderCalled(Code) | | |
queryStringLen | int queryStringLen(Code) | | |
queryStringStart | int queryStringStart(Code) | | |
HttpRequest | public HttpRequest(WebWorker w)(Code) | | Using the specified worker's input stream, read an HTTP request,
and construct a new HttpRequest object to represent it.
Parameters: w - the worker |
badRequest | boolean badRequest()(Code) | | |
getAttribute | public Object getAttribute(String name)(Code) | | Returns the value of the named attribute of the request, or
null if the attribute does not exist.
Parameters: name - the name of the attribute whose value is required |
getAttributeNames | public Enumeration getAttributeNames()(Code) | | Return an enumeration of all attribute names of this service
|
getAuthType | public String getAuthType()(Code) | | Gets the authentication scheme of this request. Same as the CGI
variable AUTH_TYPE.
this request's authentication scheme, or null if none. |
getCharacterEncoding | public String getCharacterEncoding()(Code) | | Returns the character set encoding for the input of this request.
|
getContentLength | public int getContentLength()(Code) | | Returns the size of the request entity data, or -1 if not known.
Same as the CGI variable CONTENT_LENGTH.
|
getContentType | public String getContentType()(Code) | | Returns the Internet Media Type of the request entity data, or
null if not known. Same as the CGI variable CONTENT_TYPE.
|
getContextPath | public String getContextPath()(Code) | | Return the portion of the request URI that specifies the context
for this request
|
getCookies | public Cookie[] getCookies()(Code) | | Gets the array of cookies found in this request.
the array of cookies found in this request |
getDateHeader | public long getDateHeader(String name)(Code) | | Gets the value of the requested date header field of this
request. If the header can't be converted to a date, the method
throws an IllegalArgumentException. The case of the header
field name is ignored.
Parameters: name - the String containing the name of the requestedheader field the value the requested date header field, or -1 if notfound. |
getHeader | public String getHeader(String name)(Code) | | Gets the value of the requested header field of this request.
The case of the header field name is ignored.
Parameters: name - the String containing the name of the requestedheader field the value of the requested header field, or null if notknown. |
getHeaders | public Enumeration getHeaders()(Code) | | Gets the header names for this request.
an enumeration of strings representing the header namesfor this request. Some server implementations do not allowheaders to be accessed in this way, in which case this methodwill return null. |
getIntHeader | public int getIntHeader(String name)(Code) | | Gets the value of the specified integer header field of this
request. The case of the header field name is ignored. If the
header can't be converted to an integer, the method throws a
NumberFormatException.
Parameters: name - the String containing the name of the requestedheader field the value of the requested header field, or -1 if notfound. |
getLocale | public Locale getLocale()(Code) | | Return the preferred Locale that the client will accept content
from based on the Accept-Language header, or the
server default Locale
|
getMethod | public String getMethod()(Code) | | Gets the HTTP method (for example, GET, POST, PUT) with which
this request was made. Same as the CGI variable REQUEST_METHOD.
the HTTP method with which this request was made |
getParameter | public String getParameter(String name)(Code) | | Returns a string containing the lone value of the specified
parameter, or null if the parameter does not exist. For example,
in an HTTP servlet this method would return the value of the
specified query string parameter. Servlet writers should use
this method only when they are sure that there is only one value
for the parameter. If the parameter has (or could have)
multiple values, servlet writers should use
getParameterValues. If a multiple valued parameter name is
passed as an argument, the return value is implementation
dependent.
Parameters: name - the name of the parameter whose value is required. |
getParameterNames | public Enumeration getParameterNames()(Code) | | Returns the parameter names for this request as an enumeration
of strings, or an empty enumeration if there are no parameters
or the input stream is empty. The input stream would be empty
if all the data had been read from the stream returned by the
method getInputStream.
|
getParameterValues | public String[] getParameterValues(String name)(Code) | | Returns the values of the specified parameter for the request as
an array of strings, or null if the named parameter does not
exist. For example, in an HTTP servlet this method would return
the values of the specified query string or posted form as an
array of strings.
Parameters: name - the name of the parameter whose value is required. |
getPathInfo | public String getPathInfo()(Code) | | Gets any optional extra path information following the servlet
path of this request's URI, but immediately preceding its query
string. Same as the CGI variable PATH_INFO.
the optional path information following the servletpath, but before the query string, in this request's URI; nullif this request's URI contains no extra path information |
getPathTranslated | public String getPathTranslated()(Code) | | Gets any optional extra path information following the servlet
path of this request's URI, but immediately preceding its query
string, and translates it to a real path. Similar to the CGI
variable PATH_TRANSLATED
extra path information translated to a real path or nullif no extra path information is in the request's URI |
getProtocol | public String getProtocol()(Code) | | Returns the protocol and version of the request as a string of
the form <protocol>/<major version>.<minor
version> . Same as the CGI variable SERVER_PROTOCOL.
|
getQueryString | public String getQueryString()(Code) | | Gets any query string that is part of the HTTP request URI.
Same as the CGI variable QUERY_STRING.
query string that is part of this request's URI, or nullif it contains no query string |
getReader | public BufferedReader getReader() throws IOException(Code) | | Returns a buffered reader for reading text in the request body.
This translates character set encodings as appropriate.
exception: UnsupportedEncodingException - if the character set encodingis unsupported, so the text can't be correctly decoded. exception: IllegalStateException - if getInputStream has beencalled on this same request. exception: IOException - on other I/O related errors. |
getRealPath | public String getRealPath(String path)(Code) | | Applies alias rules to the specified virtual path and returns
the corresponding real path, or null if the translation can not
be performed for any reason. For example, an HTTP servlet would
resolve the path using the virtual docroot, if virtual hosting
is enabled, and with the default docroot otherwise. Calling
this method with the string "/" as an argument returns the
document root.
Parameters: path - the virtual path to be translated to a real path |
getRemoteAddr | public String getRemoteAddr()(Code) | | Returns the IP address of the agent that sent the request.
Same as the CGI variable REMOTE_ADDR.
|
getRemoteHost | public String getRemoteHost()(Code) | | Returns the fully qualified host name of the agent that sent the
request. Same as the CGI variable REMOTE_HOST.
|
getRemoteUser | public String getRemoteUser()(Code) | | Gets the name of the user making this request. The user name is
set with HTTP authentication. Whether the user name will
continue to be sent with each subsequent communication is
browser-dependent. Same as the CGI variable REMOTE_USER.
the name of the user making this request, or null if notknown. |
getRequestURI | public String getRequestURI()(Code) | | Gets, from the first line of the HTTP request, the part of this
request's URI that is to the left of any query string.
For example,
First line of HTTP request |
| Return from getRequestURI
|
---|
POST /some/path.html HTTP/1.1 | | /some/path.html
| GET http://foo.bar/a.html HTTP/1.0
| | http://foo.bar/a.html
| HEAD /xyz?a=b HTTP/1.1 | | /xyz
|
To reconstruct a URL with a URL scheme and host, use the
method javax.servlet.http.HttpUtils.getRequestURL, which returns
a StringBuffer.
this request's URI |
getRequestedSessionId | public String getRequestedSessionId()(Code) | | Gets the session id specified with this request. This may
differ from the actual session id. For example, if the request
specified an id for an invalid session, then this will get a new
session with a new id.
the session id specified by this request, or null if therequest did not specify a session id |
getScheme | public String getScheme()(Code) | | Returns the scheme of the URL used in this request, for example
"http", "https", or "ftp". Different schemes have different
rules for constructing URLs, as noted in RFC 1738. The URL used
to create a request may be reconstructed using this scheme, the
server name and port, and additional information such as URIs.
|
getServerName | public String getServerName()(Code) | | Returns the host name of the server that received the request.
Same as the CGI variable SERVER_NAME.
|
getServerPort | public int getServerPort()(Code) | | Returns the port number on which this request was received.
Same as the CGI variable SERVER_PORT.
|
getServletPath | public String getServletPath()(Code) | | Gets the part of this request's URI that refers to the servlet
being invoked. Analogous to the CGI variable SCRIPT_NAME.
the servlet being invoked, as contained in thisrequest's URI |
getSession | public HttpSession getSession(boolean create)(Code) | | Gets the current valid session associated with this request, if
create is false or, if necessary, creates a new session for the
request, if create is true.
Note: to ensure the session is properly maintained,
the servlet developer must call this method (at least once)
before any output is written to the response.
Additionally, application-writers need to be aware that newly
created sessions (that is, sessions for which
HttpSession.isNew returns true) do not have any
application-specific state.
the session associated with this request or null ifcreate was false and no valid session is associatedwith this request. |
getSession | public HttpSession getSession()(Code) | | Gets the current valid session associated with this request, and
if necessary, creates a new session for the request.
the session associated with this request. |
getToken | String getToken(OctetMap map) throws IOException(Code) | | Parsing helper: Get the next bytes all of which are in the
specified map
Parameters: map - the octet map specifying the bytes we want |
getUserPrincipal | public Principal getUserPrincipal()(Code) | | Return a Principal object indicating the identity of the user
associated with this request.
|
isRequestedSessionIdFromCookie | public boolean isRequestedSessionIdFromCookie()(Code) | | Checks whether the session id specified by this request came in
as a cookie. (The requested session may not be one returned by
the getSession method.)
true if the session id specified by this request came inas a cookie; false otherwise |
isRequestedSessionIdFromURL | public boolean isRequestedSessionIdFromURL()(Code) | | Checks whether the session id specified by this request came in
as part of the URL. (The requested session may not be the one
returned by the getSession method.)
true if the session id specified by the request for thissession came in as part of the URL; false otherwise |
isRequestedSessionIdFromUrl | public boolean isRequestedSessionIdFromUrl()(Code) | | |
isRequestedSessionIdValid | public boolean isRequestedSessionIdValid()(Code) | | Checks whether this request is associated with a session that
is valid in the current session context. If it is not valid,
the requested session will never be returned from the
getSession method.
true if this request is assocated with a session that isvalid in the current session context. |
isSecure | public boolean isSecure()(Code) | | |
isUserInRole | public boolean isUserInRole(String role)(Code) | | Returns a boolean indicating whether the authenticated user is
included in the indicated 'role'.
|
maybeParsePostData | final void maybeParsePostData()(Code) | | |
parseHttpVersion | String parseHttpVersion() throws IOException(Code) | | Parse the http version field from the request line
the http protocol and version exception: IOException - if the version field is incorrect |
parseParameters | public static void parseParameters(Hashtable params, InputStream is)(Code) | | Parse a set of parameters from the specified input stream.
Parameters: is - the input stream a table containing the parameters as String -> String[]entries. |
removeAttribute | public void removeAttribute(String name)(Code) | | Remove an attribute from the request
|
setAttribute | public void setAttribute(String name, Object obj)(Code) | | Set the value of the named attribute
Parameters: name - the name of the attribute Parameters: obj - the value |
setResponse | void setResponse(HttpResponse res)(Code) | | Associate this request with its matching response. We need this
to facilitate session management via cookies
Parameters: res - the HttpResponse that goes with this request |
|
|