Package org.apache.mina.http
Class HttpRequestImpl
- java.lang.Object
-
- org.apache.mina.http.HttpRequestImpl
-
- All Implemented Interfaces:
HttpMessage,HttpRequest
public class HttpRequestImpl extends java.lang.Object implements HttpRequest
A HTTP Request implementation
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.lang.String>headersThe set of headersprivate HttpMethodmethodThe HTTP methodprivate java.lang.StringqueryStringThe query stringprivate java.lang.StringrequestedPathThe requested pathprivate HttpVersionversionThe HTTP version
-
Constructor Summary
Constructors Constructor Description HttpRequestImpl(HttpVersion version, HttpMethod method, java.lang.String requestedPath, java.lang.String queryString, java.util.Map<java.lang.String,java.lang.String> headers)Creates a new HttpRequestImpl instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsHeader(java.lang.String name)Tells if the message contains some headerbooleancontainsParameter(java.lang.String name)Determines whether this request contains at least one parameter with the specified namejava.lang.StringgetContentType()Gets theContent-Typeheader of the message.java.lang.StringgetHeader(java.lang.String name)Returns the value of the HTTP header with the specified name.java.util.Map<java.lang.String,java.lang.String>getHeaders()HttpMethodgetMethod()Return the HTTP method used for this messageHttpMethodjava.lang.StringgetParameter(java.lang.String name)Returns the value of a request parameter as a String, or null if the parameter does not exist.java.util.Map<java.lang.String,java.util.List<java.lang.String>>getParameters()HttpVersiongetProtocolVersion()The HTTP version of the messagejava.lang.StringgetQueryString()java.lang.StringgetRequestPath()Return the HTTP request pathbooleanisKeepAlive()protected java.util.regex.MatcherparameterPattern(java.lang.String name)java.lang.StringtoString()
-
-
-
Field Detail
-
version
private final HttpVersion version
The HTTP version
-
method
private final HttpMethod method
The HTTP method
-
requestedPath
private final java.lang.String requestedPath
The requested path
-
queryString
private final java.lang.String queryString
The query string
-
headers
private final java.util.Map<java.lang.String,java.lang.String> headers
The set of headers
-
-
Constructor Detail
-
HttpRequestImpl
public HttpRequestImpl(HttpVersion version, HttpMethod method, java.lang.String requestedPath, java.lang.String queryString, java.util.Map<java.lang.String,java.lang.String> headers)
Creates a new HttpRequestImpl instance- Parameters:
version- The HTTP versionmethod- The HTTP methodrequestedPath- The request pathqueryString- The query stringheaders- The headers
-
-
Method Detail
-
getProtocolVersion
public HttpVersion getProtocolVersion()
The HTTP version of the message- Specified by:
getProtocolVersionin interfaceHttpMessage- Returns:
- HTTP/1.0 or HTTP/1.1
-
getContentType
public java.lang.String getContentType()
Gets theContent-Typeheader of the message.- Specified by:
getContentTypein interfaceHttpMessage- Returns:
- The content type.
-
isKeepAlive
public boolean isKeepAlive()
- Specified by:
isKeepAlivein interfaceHttpMessage- Returns:
trueif this message enables keep-alive connection.
-
getHeader
public java.lang.String getHeader(java.lang.String name)
Returns the value of the HTTP header with the specified name. If more than one header with the given name is associated with this request, one is selected and returned.- Specified by:
getHeaderin interfaceHttpMessage- Parameters:
name- The name of the desired header- Returns:
- The header value - or null if no header is found with the specified name
-
containsHeader
public boolean containsHeader(java.lang.String name)
Tells if the message contains some header- Specified by:
containsHeaderin interfaceHttpMessage- Parameters:
name- the Header's name we are looking for- Returns:
trueif the HTTP header with the specified name exists in this request.
-
getHeaders
public java.util.Map<java.lang.String,java.lang.String> getHeaders()
- Specified by:
getHeadersin interfaceHttpMessage- Returns:
- a read-only
Mapof HTTP headers whose key is aStringand whose value is aStrings.
-
containsParameter
public boolean containsParameter(java.lang.String name)
Determines whether this request contains at least one parameter with the specified name- Specified by:
containsParameterin interfaceHttpRequest- Parameters:
name- The parameter name- Returns:
trueif this request contains at least one parameter with the specified name
-
getParameter
public java.lang.String getParameter(java.lang.String name)
Returns the value of a request parameter as a String, or null if the parameter does not exist. If the request contained multiple parameters with the same name, this method returns the first parameter encountered in the request with the specified name- Specified by:
getParameterin interfaceHttpRequest- Parameters:
name- The parameter name- Returns:
- The value
-
parameterPattern
protected java.util.regex.Matcher parameterPattern(java.lang.String name)
-
getParameters
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getParameters()
- Specified by:
getParametersin interfaceHttpRequest- Returns:
- a read only
Mapof query parameters whose key is aStringand whose value is aListofStrings.
-
getQueryString
public java.lang.String getQueryString()
- Specified by:
getQueryStringin interfaceHttpRequest- Returns:
- The query part
-
getMethod
public HttpMethod getMethod()
Return the HTTP method used for this messageHttpMethod- Specified by:
getMethodin interfaceHttpRequest- Returns:
- the method
-
getRequestPath
public java.lang.String getRequestPath()
Return the HTTP request path- Specified by:
getRequestPathin interfaceHttpRequest- Returns:
- the request path
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-