public interface RsfHttpRequest
Modifier and Type | Method and Description |
---|---|
Object |
getAttribute(String name)
Returns the value of the named attribute as an
Object ,
or null if no attribute of the given name exists. |
Enumeration<String> |
getAttributeNames()
Returns an
Enumeration containing the
names of the attributes available to this request. |
long |
getContentLength()
Returns the length, in bytes, of the request body and made available by the input stream, or -1
if the length is not known ir is greater than Integer.MAX_VALUE.
|
String |
getHeader(String name)
Returns the value of the specified request header
as a
String . |
Enumeration<String> |
getHeaderNames()
Returns an enumeration of all the header names
this request contains.
|
Enumeration<String> |
getHeaders(String name)
Returns all the values of the specified request header
as an
Enumeration of String objects. |
InputStream |
getInputStream()
Retrieves the body of the request as binary data using a
InputStream . |
String |
getLocalAddr()
Returns the Internet Protocol (IP) address of the interface on which the request was received.
|
int |
getLocalPort()
Returns the Internet Protocol (IP) port number of the interface on which the request was received.
|
String |
getMethod()
Returns the name of the HTTP method with which this
request was made, for example, GET, POST, or PUT.
|
String |
getParameter(String name)
Returns the value of a request parameter as a
String ,
or null if the parameter does not exist. |
Enumeration<String> |
getParameterNames()
Returns an
Enumeration of String
objects containing the names of the parameters contained
in this request. |
String[] |
getParameterValues(String name)
Returns an array of
String objects containing
all of the values the given request parameter has, or
null if the parameter does not exist. |
String |
getProtocol()
Returns the name and version of the protocol the request uses
in the form protocol/majorVersion.minorVersion, for
example, HTTP/1.1.
|
String |
getQueryString()
Returns the query string that is contained in the request
URL after the path.
|
String |
getRemoteAddr()
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
|
int |
getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
|
String |
getRequestURI()
Returns the part of this request's URL from the protocol
name up to the query string in the first line of the HTTP request.
|
void |
removeAttribute(String name)
Removes an attribute from this request.
|
void |
setAttribute(String name,
Object o)
Stores an attribute in this request.
|
String getRequestURI()
First line of HTTP request | Returned Value | |
---|---|---|
POST /some/path.html HTTP/1.1 | /some/path.html | |
GET http://foo.bar/a.html HTTP/1.0 | /a.html | |
HEAD /xyz?a=b HTTP/1.1 | /xyz |
To reconstruct an URL with a scheme and host, use
String
containing the part of the URL from the protocol name up to the query stringString getQueryString()
null
if the URL does not have a query string. Same as the value
of the CGI variable QUERY_STRING.String
containing the query
string or null
if the URL
contains no query string. The value is not
decoded by the container.String getMethod()
String
specifying the name of the method with which this request was madeObject getAttribute(String name)
Object
,
or null
if no attribute of the given name exists.name
- a String
specifying the name of the attributeObject
containing the value of the attribute, or null
if the attribute does not existEnumeration<String> 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 attributesvoid setAttribute(String name, Object o)
name
- a String
specifying the name of the attributeo
- the Object
to be storedInputStream getInputStream() throws IOException
InputStream
.InputStream
object containing the body of the requestIOException
- if an input or output exception occurredvoid removeAttribute(String name)
name
- a String
specifying the name of the attribute to removelong getContentLength()
String getHeader(String name)
String
. If the request did not include a header
of the specified name, this method returns null
.
If there are multiple headers with the same name, this method
returns the first head in the request.
The header name is case insensitive. You can use
this method with any request header.name
- a String
specifying the header nameString
containing the
value of the requested
header, or null
if the request does not
have a header of that nameEnumeration<String> getHeaders(String name)
Enumeration
of String
objects.
Some headers, such as Accept-Language
can be sent
by clients as several headers each with a different value rather than
sending the header as a comma separated list.
If the request did not include any headers
of the specified name, this method returns an empty
Enumeration
.
The header name is case insensitive. You can use
this method with any request header.
name
- a String
specifying the header nameEnumeration
containing
the values of the requested header. If
the request does not have any headers of
that name return an empty
enumeration. If
the container does not allow access to
header information, return nullEnumeration<String> getHeaderNames()
Some servlet containers do not allow
servlets to access headers using this method, in
which case this method returns null
null
String getParameter(String name)
String
,
or null
if the parameter does not exist. Request parameters
are extra information sent with the request. For HTTP servlets,
parameters are contained in the query string or posted form data.
You should only use this method when you are sure the
parameter has only one value. If the parameter might have
more than one value, use getParameterValues(java.lang.String)
.
If you use this method with a multivalued
parameter, the value returned is equal to the first value
in the array returned by getParameterValues
.
If the parameter data was sent in the request body, such as occurs with an HTTP POST request,
then reading the body directly via getInputStream()
can interfere with the execution of this method.
name
- a String
specifying the name of the parameterString
representing the single value of the parametergetParameterValues(java.lang.String)
Enumeration<String> getParameterNames()
Enumeration
of String
objects containing the names of the parameters contained
in this request. If the request has
no parameters, the method returns an empty Enumeration
.Enumeration
of String
objects, each String
containing the name of
a request parameter; or an empty Enumeration
if the request has no parametersString[] getParameterValues(String name)
String
objects containing
all of the values the given request parameter has, or
null
if the parameter does not exist.
If the parameter has a single value, the array has a length of 1.
name
- a String
containing the name of the parameter whose value is requestedString
objects containing the parameter's valuesgetParameter(java.lang.String)
String getProtocol()
SERVER_PROTOCOL
.String
containing the protocol name and version numberString getRemoteAddr() throws UnknownHostException
REMOTE_ADDR
.String
containing the IP address of the client that sent the requestUnknownHostException
int getRemotePort()
String getLocalAddr() throws UnknownHostException
String
containing the IP address on which the request was received.UnknownHostException
int getLocalPort()
Copyright © 2020. All rights reserved.