|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objectorg.xlightweb.HttpRequestHeaderWrapper
org.xlightweb.HttpRequestWrapper
public class HttpRequestWrapper
Provides a convenient implementation of the HttpRequest interface that can be subclassed by developers wishing to adapt the request. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped request object.
| Field Summary |
|---|
| Fields inherited from interface org.xlightweb.IHttpMessage |
|---|
CONNECT_METHOD, DEFAULT_ENCODING, DEFAULT_ENCODING_KEY, DELETE_METHOD, GET_METHOD, HEAD_METHOD, OPTIONS_METHOD, POST_METHOD, PUT_METHOD, TRACE_METHOD |
| Fields inherited from interface org.xlightweb.IHttpMessageHeader |
|---|
DEFAULT_ENCODING |
| Constructor Summary | |
|---|---|
HttpRequestWrapper(IHttpRequest request)
constructor |
|
| Method Summary | |
|---|---|
void |
addHeader(String headername,
String headervalue)
Adds a header with the given name and value. |
void |
addHeaderLine(String line)
adds a raw header line |
void |
addHeaderlines(String... lines)
adds raw header lines |
boolean |
containsHeader(String headername)
Returns a boolean indicating whether the named header has already been set. |
BlockingBodyDataSource |
getBlockingBody()
|
BodyDataSource |
getBody()
returns the blocking body |
String |
getCharacterEncoding()
Returns the name of the character encoding used in the body of this message. |
String |
getContentType()
Returns the MIME type of the body of the messag, or null if the type is not known. |
String |
getContextPath()
Returns the portion of the request URI that indicates the context of the request. |
String |
getDisposition()
returns the content disposition header of the part, or null if the type is not known. |
String |
getDispositionParam(String name)
returns the content disposition param value or null if not setsee also rfc2183 |
String |
getDispositionType()
returns the content disposition type or null if not setsee also rfc2183 |
String |
getHeader(String headername)
Returns the value of the specified header as a String. |
String |
getHeader(String headername,
String dfltValue)
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. |
Enumeration |
getHeaderNames()
Returns an enumeration of all the header names. |
Set<String> |
getHeaderNameSet()
Returns an set of all the header names. |
Enumeration |
getHeaders(String headername)
Returns all the values of the specified header as an Enumeration of String objects. |
String |
getHost()
returns the Host header parameter or null if the header is not set |
IHttpMessageHeader |
getMessageHeader()
returns the message header |
NonBlockingBodyDataSource |
getNonBlockingBody()
returns the non-blocking body |
IHeader |
getPartHeader()
returns the part header |
String |
getPathInfo()
Returns any extra path information associated with the URL. |
String |
getPathInfo(boolean removeSurroundingSlashs)
Returns any extra path information associated with the URL. |
String |
getRequestHandlerPath()
returns the request handler path. |
IHttpRequestHeader |
getRequestHeader()
returns the request header |
String |
getUserAgent()
returns the User-Agent header parameter or null if the header is not set |
protected IHeader |
getWrappedHeader()
|
boolean |
hasBody()
returns true if the part has a body |
void |
removeHeader(String headername)
removes a header with the given name |
void |
removeParameter(String parameterName)
remove a parameter |
void |
setContextPath(String contextPath)
sets the context path. |
void |
setHeader(String headername,
String headervalue)
Sets a header with the given name and value. |
void |
setHost(String host)
sets the Host header (e.g. www.gmx.com or www.gmx.com:9900). |
void |
setParameter(String parameterName,
String parameterValue)
sets a parameter |
void |
setRequestHandlerPath(String requestHandlerPath)
sets the request handler path |
void |
setUserAgent(String userAgent)
sets the User-Agent header |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.xlightweb.IHttpMessage |
|---|
getAttribute, getAttributeNames, getAttributeNameSet, getCharacterEncoding, getContentLength, getContentType, getProtocol, getProtocolVersion, getTransferEncoding, removeHopByHopHeaders, setAttribute, setContentLength, setContentType, setTransferEncoding |
| Methods inherited from interface org.xlightweb.IHeader |
|---|
addHeader, addHeaderLine, addHeaderlines, containsHeader, getDisposition, getDispositionParam, getDispositionType, getHeader, getHeader, getHeaderList, getHeaderNames, getHeaderNameSet, getHeaders, removeHeader, setHeader |
| Constructor Detail |
|---|
public HttpRequestWrapper(IHttpRequest request)
request - the request to wrap| Method Detail |
|---|
public String getContextPath()
getContextPath in interface IHttpRequestgetContextPath in interface IHttpRequestHeadergetContextPath in class HttpRequestHeaderWrapperIHttpRequest.getRequestHandlerPath()public String getPathInfo()
getPathInfo in interface IHttpRequestgetPathInfo in interface IHttpRequestHeadergetPathInfo in class HttpRequestHeaderWrappernull if the URL does not have any extra path informationpublic String getPathInfo(boolean removeSurroundingSlashs)
getPathInfo in interface IHttpRequestgetPathInfo in interface IHttpRequestHeadergetPathInfo in class HttpRequestHeaderWrapperremoveSurroundingSlashs - true, if surrounding slashs wil lbe removed
null if the URL does not have any extra path informationpublic String getRequestHandlerPath()
getRequestHandlerPath in interface IHttpRequestgetRequestHandlerPath in interface IHttpRequestHeadergetRequestHandlerPath in class HttpRequestHeaderWrapperpublic IHttpRequestHeader getRequestHeader()
getRequestHeader in interface IHttpRequestpublic String getHost()
null if the header is not set
getHost in interface IHttpRequestgetHost in interface IHttpRequestHeadergetHost in class HttpRequestHeaderWrappernull if the header is not setpublic String getUserAgent()
null if the header is not set
getUserAgent in interface IHttpRequestgetUserAgent in interface IHttpRequestHeadergetUserAgent in class HttpRequestHeaderWrappernull if the header is not setpublic void setHost(String host)
setHost in interface IHttpRequestsetHost in interface IHttpRequestHeadersetHost in class HttpRequestHeaderWrapperhost - the Host headerpublic void setUserAgent(String userAgent)
setUserAgent in interface IHttpRequestsetUserAgent in interface IHttpRequestHeadersetUserAgent in class HttpRequestHeaderWrapperuserAgent - the User-Agent headerpublic void setContextPath(String contextPath)
setContextPath in interface IHttpRequestsetContextPath in interface IHttpRequestHeadersetContextPath in class HttpRequestHeaderWrappercontextPath - the context path
public void setParameter(String parameterName,
String parameterValue)
setParameter in interface IHttpRequestsetParameter in interface IHttpRequestHeadersetParameter in class HttpRequestHeaderWrapperparameterName - the parameter nameparameterValue - the parameter valuepublic void removeParameter(String parameterName)
removeParameter in interface IHttpRequestremoveParameter in interface IHttpRequestHeaderremoveParameter in class HttpRequestHeaderWrapperparameterName - the parameter namepublic void setRequestHandlerPath(String requestHandlerPath)
setRequestHandlerPath in interface IHttpRequestsetRequestHandlerPath in interface IHttpRequestHeadersetRequestHandlerPath in class HttpRequestHeaderWrapperrequestHandlerPath - the request handler path
public BlockingBodyDataSource getBlockingBody()
throws IOException
getBlockingBody in interface IPartIOException
public BodyDataSource getBody()
throws IOException
IPart
getBody in interface IPartnull if part is bodyless
IOExceptionpublic IHttpMessageHeader getMessageHeader()
getMessageHeader in interface IHttpMessagepublic IHeader getPartHeader()
getPartHeader in interface IPart
public NonBlockingBodyDataSource getNonBlockingBody()
throws IOException
getNonBlockingBody in interface IPartnull if parte is bodyless
IOExceptionpublic boolean hasBody()
hasBody in interface IPartpublic String toString()
toString in class HttpRequestHeaderWrapperprotected IHeader getWrappedHeader()
public void addHeader(String headername,
String headervalue)
addHeader in interface IHeaderheadername - the name of the headerheadervalue - the additional header value. If it contains octet string, it should be encoded
according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)public void addHeaderLine(String line)
addHeaderLine in interface IHeaderline - the headerlinepublic void addHeaderlines(String... lines)
addHeaderlines in interface IHeaderlines - the headerlinespublic boolean containsHeader(String headername)
containsHeader in interface IHeadertrue if the named header has already been set; false otherwisepublic String getCharacterEncoding()
getCharacterEncoding in interface IHeaderString containing the name of the character encodingpublic String getContentType()
null if the type is not known.
getContentType in interface IHeaderString containing the name of the MIME type of
the message, or null if the type is not knownpublic String getDisposition()
null if the type is not known.
getDisposition in interface IHeaderString containing the name of the content disposition of
the part, or null if the type is not knownpublic String getDispositionType()
null if not set
getDispositionType in interface IHeadernull if not setpublic String getDispositionParam(String name)
null if not set
getDispositionParam in interface IHeadername - the parameter name
null if not setpublic 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 IHeaderheadername - 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 name
public String getHeader(String headername,
String dfltValue)
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 IHeaderheadername - a String specifying the header namedfltValue - the default value if the header is not set
String containing the value of the
requested header, or null if the part
does not have a header of that namepublic 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 IHeaderheadername - 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 Set<String> getHeaderNameSet()
getHeaderNameSet in interface IHeaderpublic Enumeration getHeaderNames()
getHeaderNames in interface IHeaderpublic Enumeration getHeaders(String headername)
Enumeration 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.
getHeaders in interface IHeaderheadername - a String specifying the header name
Enumeration containing the values of the requested header.
If the part does not have any headers of that name return an empty enumeration.public void removeHeader(String headername)
removeHeader in interface IHeaderheadername - the name of the header
public void setHeader(String headername,
String headervalue)
setHeader in interface IHeaderheadername - the name of the headerheadervalue - the header value If it contains octet string,
it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||