|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IHttpRequest
Http Request
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 |
Method Summary | |
---|---|
void |
addMatrixParameter(String parameterName,
String parameterValue)
adds a matrix parameter |
void |
addParameter(String parameterName,
String parameterValue)
adds a parameter |
List<ContentType> |
getAccept()
returns the list of the accepted content types, ordered by the quality factory |
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. |
String |
getContextPath()
Returns the portion of the request URI that indicates the context of the request. |
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 |
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 |
getPathInfo()
Returns any extra path information associated with the URL. |
String |
getPathInfo(boolean removeSurroundingSlashs)
Returns any extra path information associated with the URL. |
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 message. |
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 message. |
String |
getRequestHandlerPath()
returns the request handler path. |
IHttpRequestHeader |
getRequestHeader()
returns the request header |
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. |
void |
removeMatrixParameter(String parameterName)
removes a matrix parameter |
void |
removeParameter(String parameterName)
remove a parameter |
void |
setContextPath(String contextPath)
sets the context path. |
void |
setHost(String host)
sets the Host header |
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 |
setRequestHandlerPath(String requestHandlerPath)
sets the request handler path |
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 |
Methods inherited from interface org.xlightweb.IHttpMessage |
---|
getAttribute, getAttributeNames, getAttributeNameSet, getCharacterEncoding, getContentLength, getContentType, getMessageHeader, getProtocol, getProtocolVersion, getTransferEncoding, removeHopByHopHeaders, setAttribute, setContentLength, setContentType, setTransferEncoding |
Methods inherited from interface org.xlightweb.IPart |
---|
getBlockingBody, getBody, getNonBlockingBody, getPartHeader, hasBody |
Methods inherited from interface org.xlightweb.IHeader |
---|
addHeader, addHeaderLine, addHeaderlines, containsHeader, getDisposition, getDispositionParam, getDispositionType, getHeader, getHeaderList, getHeaderNames, getHeaderNameSet, getHeaders, removeHeader, setHeader |
Method Detail |
---|
IHttpRequestHeader getRequestHeader()
String getRequestHandlerPath()
class MyHandler implements IHttpRequestHandler { public void onRequest(IHttpExchange exchange) throws IOException,BadMessageException { IHttpRequest req = exchange.getRequest(); StringBuilder sb = new StringBuilder(); sb.append("path=" + req.getRequestHandlerPath() + "\r\n"); sb.append("ctx=" + req.getContextPath() + "\r\n"); sb.append("uri=" + req.getRequestURI() + "\r\n"); exchange.send(new HttpResponse(200, "text/plain", sb.toString())); } } ... Context ctx = new Context("/ctx/subctx"); ctx.addHandler("/hdlPath/*", new MyHandler()); HttpServer server = new HttpServer(ctx); server.start(); HttpClient httpClient = new HttpClient(); IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/ctx/subctx/hdlPath/test?param=value")); System.out.println(response.getBlockingBody().readString()); // prints out: // >path=/hdlPath // >ctx=/ctx/subctx // >uri=/ctx/subctx/hdlPath/test ...
void setRequestHandlerPath(String requestHandlerPath)
requestHandlerPath
- the request handler pathString getContextPath()
getRequestHandlerPath()
void setContextPath(String contextPath)
contextPath
- the context pathvoid setMethod(String method)
method
- a String specifying the name of the methodString getMethod()
String getServerName()
int getServerPort()
URL getRequestUrl()
void setRequestUrl(URL url)
url
- the request urlvoid setHost(String host)
host
- the Host headerString getHost()
null
if the header is not set
null
if the header is not setString getUserAgent()
null
if the header is not set
null
if the header is not setvoid setUserAgent(String userAgent)
userAgent
- the User-Agent headerList<ContentType> getAccept()
String getScheme()
String getRemoteHost()
int getRemotePort()
String getRemoteAddr()
String getRequestURI()
void setRequestURI(String requestUri)
requestUri
- the request uriString getPathInfo()
null
if the URL does not have any extra path informationString getPathInfo(boolean removeSurroundingSlashs)
removeSurroundingSlashs
- true, if surrounding slashs wil lbe removed
null
if the URL does not have any extra path informationString getQueryString()
null
if the URL does not have a query string.
null
if the URL contains no query string.boolean isSecure()
Set<String> getMatrixParameterNameSet()
String getMatrixParameter(String name)
name
- a String specifying the name of the matrix parameter
String[] getMatrixParameterValues(String name)
name
- a String specifying the name of the matrix parameter
void setMatrixParameter(String parameterName, String parameterValue)
parameterName
- the parameter nameparameterValue
- the parameter valuevoid addMatrixParameter(String parameterName, String parameterValue)
parameterName
- the parameter nameparameterValue
- the parameter valuevoid removeMatrixParameter(String parameterName)
parameterName
- the parameter nameSet<String> getParameterNameSet()
Enumeration getParameterNames()
String getParameter(String name)
name
- a String specifying the name of the parameter
String getParameter(String name, String defaultVal)
name
- the name of the parameterdefaultVal
- the default value to use as fallback
String[] getParameterValues(String name)
name
- a String specifying the name of the parameter
String getRequiredStringParameter(String name) throws BadMessageException
name
- the parameter name
BadMessageException
- if the parameter is not presentInteger getIntParameter(String name) throws BadMessageException
name
- the name of the parameter
null
BadMessageException
- if the parameter value is not a numberint getRequiredIntParameter(String name) throws BadMessageException
name
- the parameter name
BadMessageException
- if the parameter is not present or the parameter is not a numberint getIntParameter(String name, int defaultVal)
name
- the name of the parameterdefaultVal
- the default value to use as fallback
null
Long getLongParameter(String name) throws BadMessageException
name
- the name of the parameter
null
BadMessageException
- if the parameter value is not a numberlong getRequiredLongParameter(String name) throws BadMessageException
name
- the parameter name
BadMessageException
- if the parameter is not present or the parameter is not a numberlong getLongParameter(String name, long defaultVal)
name
- the name of the parameterdefaultVal
- the default value to use as fallback
Double getDoubleParameter(String name) throws BadMessageException
name
- the name of the parameter
null
BadMessageException
- if the parameter is not a numberdouble getRequiredDoubleParameter(String name) throws BadMessageException
name
- the parameter name
BadMessageException
- if the parameter is not present or the parameter value is not a numberdouble getDoubleParameter(String name, double defaultVal)
name
- the name of the parameterdefaultVal
- the default value to use as fallback
Float getFloatParameter(String name) throws BadMessageException
name
- the name of the parameter
null
BadMessageException
- if the parameter value is not a numberfloat getRequiredFloatParameter(String name) throws BadMessageException
name
- the parameter name
BadMessageException
- if the parameter is not present or the parameter value is not a numberfloat getFloatParameter(String name, float defaultVal)
name
- the name of the parameterdefaultVal
- the default value to use as fallback
Boolean getBooleanParameter(String name)
name
- the name of the parameter
null
boolean getRequiredBooleanParameter(String name) throws BadMessageException
name
- the parameter name
BadMessageException
- if the parameter is not presentboolean getBooleanParameter(String name, boolean defaultVal)
name
- the name of the parameterdefaultVal
- the default value to use as fallback
void setParameter(String parameterName, String parameterValue)
parameterName
- the parameter nameparameterValue
- the parameter valuevoid removeParameter(String parameterName)
parameterName
- the parameter nameparameterValue
- the parameter valuevoid addParameter(String parameterName, String parameterValue)
parameterName
- the parameter nameparameterValue
- the parameter value
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |