|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xlightweb.Header
org.xlightweb.HttpRequestHeader
public class HttpRequestHeader
http request header
Field Summary |
---|
Fields inherited from interface org.xlightweb.IHttpMessageHeader |
---|
DEFAULT_ENCODING |
Constructor Summary | |
---|---|
HttpRequestHeader(String method,
String url)
constructor |
|
HttpRequestHeader(String method,
String url,
String contentType)
constructor |
Method Summary | |
---|---|
void |
addMatrixParameter(String parameterName,
String parameterValue)
adds a matrix parameter |
void |
addParameter(String parameterName,
String parameterValue)
adds a parameter |
protected Object |
clone()
|
boolean |
containsHeader(String headername)
Returns a boolean indicating whether the named header has already been set. |
IHttpRequestHeader |
copy()
creates a copy of this header |
void |
copyHeaderFrom(IHttpMessageHeader otherHeader,
String... upperExcludenames)
copy the headers |
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 |
getAttributeNames()
Returns an Enumeration containing the
names of the attributes available to this message. |
Set<String> |
getAttributeNameSet()
Returns an Set containing the
names of the attributes available to this messaget. |
Boolean |
getBooleanParameter(String name)
Get an Boolean parameter, or null if not present. |
boolean |
getBooleanParameter(String name,
boolean defaultVal)
Get an boolean parameter, with a fallback value. |
int |
getContentLength()
Returns the length, in bytes, of the message body and made available by the input stream, or -1 if the length is not known. |
Double |
getDoubleParameter(String name)
Get an Double parameter, or null if not present. |
double |
getDoubleParameter(String name,
double defaultVal)
Get an double parameter, with a fallback value. |
Float |
getFloatParameter(String name)
Get an Float parameter, or null if not present. |
float |
getFloatParameter(String name,
float defaultVal)
Get an float parameter, with a fallback value. |
String |
getHeader(String headername)
Returns the value of the specified header as a String . |
List<String> |
getHeaderList(String headername)
Returns all the values of the specified header as an List of String objects. |
Set<String> |
getHeaderNameSet()
Returns an set of all the header names. |
String |
getHost()
returns the Host header parameter or null if the header is not set |
Integer |
getIntParameter(String name)
Get an Integer parameter, or null if not present. |
int |
getIntParameter(String name,
int defaultVal)
Get an int parameter, with a fallback value. |
Long |
getLongParameter(String name)
Get an Long parameter, or null if not present. |
long |
getLongParameter(String name,
long defaultVal)
Get an long parameter, with a fallback value. |
String |
getMatrixParameter(String name)
Returns the value of a request matrix parameter as a String, or null if the parameter does not exist. |
Set<String> |
getMatrixParameterNameSet()
returns the matrix parameter name set |
String[] |
getMatrixParameterValues(String name)
Returns an array of String objects containing all of the values the given request matrix parameter has, or null if the parameter does not exist. |
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. |
String |
getParameter(String name,
String defaultVal)
Get an String parameter, with a fallback value. |
Enumeration |
getParameterNames()
Returns an Enumeration of String objects containing the names of the parameters contained in this request. |
Set<String> |
getParameterNameSet()
returns the parameter name set |
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 message uses in the form protocol/majorVersion.minorVersion, for example, HTTP/1.1. |
String |
getProtocolVersion()
Returns the version of the protocol the message uses in the form majorVersion.minorVersion, for example, 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. |
String |
getRemoteHost()
Returns the fully qualified name of the client or the 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. |
URL |
getRequestUrl()
Reconstructs the URL the client used to make the request. |
boolean |
getRequiredBooleanParameter(String name)
Get an boolean parameter or throws an exception if parameter is not present |
double |
getRequiredDoubleParameter(String name)
Get an double parameter or throws an exception if parameter is not present |
float |
getRequiredFloatParameter(String name)
Get an float parameter or throws an exception if parameter is not present |
int |
getRequiredIntParameter(String name)
Get an int parameter or throws an exception if parameter is not present |
long |
getRequiredLongParameter(String name)
Get an long parameter or throws an exception if parameter is not present |
String |
getRequiredStringParameter(String name)
Get an string parameter or throws an exception if parameter is not present |
String |
getScheme()
Returns the name of the scheme used to make this request, for example, http or https. |
String |
getServerName()
Returns the host name of the server to which the request was sent. |
int |
getServerPort()
Returns the port number to which the request was sent. |
String |
getUserAgent()
returns the User-Agent header parameter or null if the header is not set |
boolean |
isSecure()
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS. |
protected boolean |
onHeaderAdded(String headername,
String headervalue)
|
protected boolean |
onHeaderRemoved(String headername)
|
void |
removeHopByHopHeaders()
removes all hop-by-hop headers without Transfer-Encoding if set to chunked |
void |
removeMatrixParameter(String parameterName)
removes a matrix parameter |
void |
removeParameter(String parameterName)
remove a parameter |
void |
setAttribute(String name,
Object o)
Stores an attribute in this header. |
void |
setContentLength(int contentLength)
sets the content length in bytes |
void |
setHost(String host)
sets the Host header (e.g. www.gmx.com or www.gmx.com:9900). |
void |
setMatrixParameter(String parameterName,
String parameterValue)
sets a matrix parameter |
void |
setMethod(String method)
Sets the name of the HTTP method |
void |
setParameter(String parameterName,
String parameterValue)
sets a parameter |
void |
setRequestURI(String requestUri)
set the request uri part of this request's URL from the protocol name up to the query string in the first line of the HTTP request. |
void |
setRequestUrl(URL url)
set the request url |
void |
setUserAgent(String userAgent)
sets the User-Agent header |
String |
toString()
|
Methods inherited from class org.xlightweb.Header |
---|
addHeader, addHeaderLine, addHeaderlines, getAccept, getCharacterEncoding, getContentType, getDisposition, getDispositionParam, getDispositionType, getHeaderNames, getHeaders, getTransferEncoding, removeHeader, setContentType, setHeader, setTransferEncoding |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.xlightweb.IHttpRequestHeader |
---|
getAccept |
Methods inherited from interface org.xlightweb.IHttpMessageHeader |
---|
copyHeaderFrom, getAttribute, getAttributeNames, getAttributeNameSet, getContentLength, getProtocol, getProtocolVersion, removeHopByHopHeaders, setAttribute, setContentLength |
Methods inherited from interface org.xlightweb.IHeader |
---|
addHeader, addHeaderLine, addHeaderlines, getCharacterEncoding, getContentType, getDisposition, getDispositionParam, getDispositionType, getHeaderNames, getHeaders, getTransferEncoding, removeHeader, setContentType, setHeader, setTransferEncoding |
Constructor Detail |
---|
public HttpRequestHeader(String method, String url)
method
- the methodurl
- the url stringpublic HttpRequestHeader(String method, String url, String contentType)
method
- the methodurl
- the url stringcontentType
- the content typeMethod Detail |
---|
protected final boolean onHeaderAdded(String headername, String headervalue)
protected final boolean onHeaderRemoved(String headername)
public final String getHost()
null
if the header is not set
getHost
in interface IHttpRequestHeader
null
if the header is not setpublic final void setHost(String host)
setHost
in interface IHttpRequestHeader
host
- the Host headerpublic final String getUserAgent()
null
if the header is not set
getUserAgent
in interface IHttpRequestHeader
null
if the header is not setpublic final void setUserAgent(String userAgent)
setUserAgent
in interface IHttpRequestHeader
userAgent
- the User-Agent headerpublic final Set<String> getHeaderNameSet()
getHeaderNameSet
in interface IHeader
public final List<String> getHeaderList(String headername)
List
of String
objects.
Some headers, such as Accept-Language
can be set
by part producer as several headers each with a different value rather than
sending the header as a comma separated list.
getHeaderList
in interface IHeader
headername
- a String
specifying the header name
List
containing the values of the requested header.
If the part does not have any headers of that name return an empty enumeration.public final String getHeader(String headername)
String
.
If the part 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 part.
getHeader
in interface IHeader
headername
- a String
specifying the header name
String
containing the value of the
requested header, or null
if the part
does not have a header of that namepublic final boolean containsHeader(String headername)
containsHeader
in interface IHeader
true
if the named header has already been set; false
otherwisepublic final String getRemoteHost()
getRemoteHost
in interface IHttpRequestHeader
public final int getRemotePort()
getRemotePort
in interface IHttpRequestHeader
public final String getRemoteAddr()
getRemoteAddr
in interface IHttpRequestHeader
public final String getQueryString()
null
if the URL does not have a query string.
getQueryString
in interface IHttpRequestHeader
public final String getRequestURI()
getRequestURI
in interface IHttpRequestHeader
public final void setRequestURI(String requestUri)
setRequestURI
in interface IHttpRequestHeader
requestUri
- the request uripublic final URL getRequestUrl()
getRequestUrl
in interface IHttpRequestHeader
public final void setRequestUrl(URL url)
setRequestUrl
in interface IHttpRequestHeader
url
- the request urlpublic final boolean isSecure()
isSecure
in interface IHttpRequestHeader
public final String getScheme()
getScheme
in interface IHttpRequestHeader
public final String getMethod()
getMethod
in interface IHttpRequestHeader
public final void setMethod(String method)
setMethod
in interface IHttpRequestHeader
method
- a String specifying the name of the methodpublic final String getServerName()
getServerName
in interface IHttpRequestHeader
public final int getServerPort()
getServerPort
in interface IHttpRequestHeader
public final void removeParameter(String parameterName)
removeParameter
in interface IHttpRequestHeader
parameterName
- the parameter namepublic final void setParameter(String parameterName, String parameterValue)
setParameter
in interface IHttpRequestHeader
parameterName
- the parameter nameparameterValue
- the parameter valuepublic final void addParameter(String parameterName, String parameterValue)
addParameter
in interface IHttpRequestHeader
parameterName
- the parameter nameparameterValue
- the parameter valuepublic final Enumeration getParameterNames()
getParameterNames
in interface IHttpRequestHeader
public final Set<String> getParameterNameSet()
getParameterNameSet
in interface IHttpRequestHeader
public final String getParameter(String name, String defaultVal)
getParameter
in interface IHttpRequestHeader
name
- the name of the parameterdefaultVal
- the default value to use as fallback
public final String getParameter(String name)
getParameter
in interface IHttpRequestHeader
name
- a String specifying the name of the parameter
public final void setMatrixParameter(String parameterName, String parameterValue)
setMatrixParameter
in interface IHttpRequestHeader
parameterName
- the parameter nameparameterValue
- the parameter valuepublic final void addMatrixParameter(String parameterName, String parameterValue)
addMatrixParameter
in interface IHttpRequestHeader
parameterName
- the parameter nameparameterValue
- the parameter valuepublic final void removeMatrixParameter(String parameterName)
removeMatrixParameter
in interface IHttpRequestHeader
parameterName
- the parameter namepublic final String[] getMatrixParameterValues(String name)
getMatrixParameterValues
in interface IHttpRequestHeader
name
- a String specifying the name of the matrix parameter
public final Set<String> getMatrixParameterNameSet()
getMatrixParameterNameSet
in interface IHttpRequestHeader
public final String getMatrixParameter(String name)
getMatrixParameter
in interface IHttpRequestHeader
name
- a String specifying the name of the matrix parameter
public final String[] getParameterValues(String name)
getParameterValues
in interface IHttpRequestHeader
name
- a String specifying the name of the parameter
public final String getRequiredStringParameter(String name) throws BadMessageException
getRequiredStringParameter
in interface IHttpRequestHeader
name
- the parameter name
BadMessageException
- if the parameter is not presentpublic final Integer getIntParameter(String name) throws BadMessageException
getIntParameter
in interface IHttpRequestHeader
name
- the name of the parameter
null
BadMessageException
- if the parameter value is not a numberpublic final int getRequiredIntParameter(String name) throws BadMessageException
getRequiredIntParameter
in interface IHttpRequestHeader
name
- the parameter name
BadMessageException
- if the parameter is not present or the parameter is not a numberpublic final int getIntParameter(String name, int defaultVal)
getIntParameter
in interface IHttpRequestHeader
name
- the name of the parameterdefaultVal
- the default value to use as fallback
public final Long getLongParameter(String name) throws BadMessageException
getLongParameter
in interface IHttpRequestHeader
name
- the name of the parameter
null
BadMessageException
- if the parameter value is not a numberpublic final long getRequiredLongParameter(String name) throws BadMessageException
getRequiredLongParameter
in interface IHttpRequestHeader
name
- the parameter name
BadMessageException
- if the parameter is not present or the parameter is not a numberpublic final long getLongParameter(String name, long defaultVal)
getLongParameter
in interface IHttpRequestHeader
name
- the name of the parameterdefaultVal
- the default value to use as fallback
public final Double getDoubleParameter(String name) throws BadMessageException
getDoubleParameter
in interface IHttpRequestHeader
name
- the name of the parameter
null
BadMessageException
- if the parameter is not a numberpublic final double getRequiredDoubleParameter(String name) throws BadMessageException
getRequiredDoubleParameter
in interface IHttpRequestHeader
name
- the parameter name
BadMessageException
- if the parameter is not present or the parameter value is not a numberpublic final double getDoubleParameter(String name, double defaultVal)
getDoubleParameter
in interface IHttpRequestHeader
name
- the name of the parameterdefaultVal
- the default value to use as fallback
public final Float getFloatParameter(String name) throws BadMessageException
getFloatParameter
in interface IHttpRequestHeader
name
- the name of the parameter
null
BadMessageException
- if the parameter value is not a numberpublic final float getRequiredFloatParameter(String name) throws BadMessageException
getRequiredFloatParameter
in interface IHttpRequestHeader
name
- the parameter name
BadMessageException
- if the parameter is not present or the parameter value is not a numberpublic final float getFloatParameter(String name, float defaultVal)
getFloatParameter
in interface IHttpRequestHeader
name
- the name of the parameterdefaultVal
- the default value to use as fallback
public final Boolean getBooleanParameter(String name)
getBooleanParameter
in interface IHttpRequestHeader
name
- the name of the parameter
null
public final boolean getRequiredBooleanParameter(String name) throws BadMessageException
getRequiredBooleanParameter
in interface IHttpRequestHeader
name
- the parameter name
BadMessageException
- if the parameter is not presentpublic final boolean getBooleanParameter(String name, boolean defaultVal)
getBooleanParameter
in interface IHttpRequestHeader
name
- the name of the parameterdefaultVal
- the default value to use as fallback
public String toString()
toString
in class Header
public final IHttpRequestHeader copy()
copy
in interface IHttpMessageHeader
copy
in interface IHttpRequestHeader
protected Object clone() throws CloneNotSupportedException
CloneNotSupportedException
public String getProtocolVersion()
getProtocolVersion
in interface IHttpMessageHeader
public String getProtocol()
getProtocol
in interface IHttpMessageHeader
public final void setAttribute(String name, Object o)
setAttribute
in interface IHttpMessageHeader
name
- a String
specifying
the name of the attributeo
- the Object
to be storedpublic final Object getAttribute(String name)
Object
,
or null
if no attribute of the given name exists.
getAttribute
in interface IHttpMessageHeader
name
- a String
specifying the name of the attribute
Object
containing the value of the attribute,
or null
if the attribute does not existpublic final Set<String> getAttributeNameSet()
Set
containing the
names of the attributes available to this messaget.
This method returns an empty Set
if the request has no attributes available to it.
getAttributeNameSet
in interface IHttpMessageHeader
Set
of strings
containing the names of the message's attributespublic final Enumeration getAttributeNames()
Enumeration
containing the
names of the attributes available to this message.
This method returns an empty Enumeration
if the message has no attributes available to it.
getAttributeNames
in interface IHttpMessageHeader
Enumeration
of strings containing the names
of the message's attributespublic final int getContentLength()
getContentLength
in interface IHttpMessageHeader
public final void setContentLength(int contentLength)
setContentLength
in interface IHttpMessageHeader
contentLength
- the content length in bytespublic final void copyHeaderFrom(IHttpMessageHeader otherHeader, String... upperExcludenames)
copyHeaderFrom
in interface IHttpMessageHeader
otherHeader
- the other headerupperExcludenames
- the header names to excludepublic final void removeHopByHopHeaders()
removeHopByHopHeaders
in interface IHttpMessageHeader
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |