Package org.hcjf.io.net.http
Class HttpRequest
- java.lang.Object
-
- org.hcjf.io.net.http.HttpPackage
-
- org.hcjf.io.net.http.HttpRequest
-
- Direct Known Subclasses:
LayeredRequest
public class HttpRequest extends HttpPackage
This particular kind of package contains the request information.- Author:
- javaito
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHttpRequest.AttachFileThis class represents a file attached into the request.-
Nested classes/interfaces inherited from class org.hcjf.io.net.http.HttpPackage
HttpPackage.ChunkedDecoderLayer, HttpPackage.HttpProtocol, HttpPackage.TransferDecodingLayerInterface
-
-
Field Summary
-
Fields inherited from class org.hcjf.io.net.http.HttpPackage
HTTP_CONTEXT_SEPARATOR, HTTP_FIELD_ASSIGNATION, HTTP_FIELD_SEPARATOR, HTTP_FIELD_START, LINE_FIELD_SEPARATOR, STRING_LINE_SEPARATOR
-
-
Constructor Summary
Constructors Modifier Constructor Description HttpRequest()HttpRequest(java.lang.String requestPath, HttpMethod method)protectedHttpRequest(HttpRequest httpRequest)
-
Method Summary
Modifier and Type Method Description voidaddHttpParameter(java.lang.String parameterName, java.lang.String parameterValue)Add parameter.java.lang.StringgetContext()Return the request context.HttpMethodgetMethod()Return the request method.<O> OgetParameter(java.lang.String parameterName)Return the parameter indexed by the argument name.java.util.Map<java.lang.String,java.lang.Object>getParameters()Return the request parameters.java.lang.StringgetPath()Return the request pathjava.util.List<java.lang.String>getPathParts()Return a list with all the parts of the request path.byte[]getProtocolHeader()Return the bytes that represent the string of the protocol name.java.lang.StringgetReplaceableValue(java.lang.String placeName)Returns the value that corresponds with the place named with the name indicated.booleanhasParameter(java.lang.String name)Returns true if the request contains the parameter indicated.protected voidprocessBody()This method process the body of the complete request.protected voidprocessFirstLine(java.lang.String firstLine)Process the first line of the request.voidsetContext(java.lang.String context)Set the request context.voidsetMatcher(java.util.regex.Matcher matcher)This method set the matche that results of the match between the context regex and the url invoked with the request.voidsetMethod(HttpMethod method)Set the request method.voidsetPath(java.lang.String path)Set the request path.java.lang.StringtoString()Creates the string representation of the package.-
Methods inherited from class org.hcjf.io.net.http.HttpPackage
addCookie, addData, addHeader, bodyDone, containsCookie, containsHeader, getBody, getCookie, getCookies, getHeader, getHeaders, getHttpVersion, getProtocol, isComplete, setBody, setHttpVersion, setProtocol, trimBody
-
-
-
-
Constructor Detail
-
HttpRequest
public HttpRequest(java.lang.String requestPath, HttpMethod method)
-
HttpRequest
protected HttpRequest(HttpRequest httpRequest)
-
HttpRequest
public HttpRequest()
-
-
Method Detail
-
getPath
public final java.lang.String getPath()
Return the request path- Returns:
- Request path.
-
setPath
public final void setPath(java.lang.String path)
Set the request path.- Parameters:
path- Request path.
-
getContext
public final java.lang.String getContext()
Return the request context.- Returns:
- Request context.
-
setContext
public final void setContext(java.lang.String context)
Set the request context.- Parameters:
context- Request context.
-
getMethod
public final HttpMethod getMethod()
Return the request method.- Returns:
- Request method.
-
setMethod
public final void setMethod(HttpMethod method)
Set the request method.- Parameters:
method- Request method.
-
hasParameter
public final boolean hasParameter(java.lang.String name)
Returns true if the request contains the parameter indicated.- Parameters:
name- Name of the parameter.- Returns:
- True if the parameter is present and false in the otherwise.
-
getParameters
public final java.util.Map<java.lang.String,java.lang.Object> getParameters()
Return the request parameters.- Returns:
- Request parameters.
-
getParameter
public final <O> O getParameter(java.lang.String parameterName)
Return the parameter indexed by the argument name.- Type Parameters:
O- Expected response type- Parameters:
parameterName- Name of the founding parameter.- Returns:
- Return the parameter.
-
getReplaceableValue
public final java.lang.String getReplaceableValue(java.lang.String placeName)
Returns the value that corresponds with the place named with the name indicated.- Parameters:
placeName- Name of the place.- Returns:
- Value replaced into the place.
-
setMatcher
public final void setMatcher(java.util.regex.Matcher matcher)
This method set the matche that results of the match between the context regex and the url invoked with the request.- Parameters:
matcher- Matcher instance.
-
addHttpParameter
public final void addHttpParameter(java.lang.String parameterName, java.lang.String parameterValue)Add parameter.- Parameters:
parameterName- Parameter name.parameterValue- Parameter value.
-
getPathParts
public final java.util.List<java.lang.String> getPathParts()
Return a list with all the parts of the request path. If the path is /path1/path2/pathN, then the method response with a list ad [path1,path2,pathN]- Returns:
- List with all the parts of the request path.
-
processBody
protected void processBody()
This method process the body of the complete request.- Specified by:
processBodyin classHttpPackage
-
processFirstLine
protected void processFirstLine(java.lang.String firstLine)
Process the first line of the request.- Specified by:
processFirstLinein classHttpPackage- Parameters:
firstLine- First line of the request.
-
getProtocolHeader
public final byte[] getProtocolHeader()
Return the bytes that represent the string of the protocol name.- Specified by:
getProtocolHeaderin classHttpPackage- Returns:
- Protocol name bytes.
-
toString
public java.lang.String toString()
Creates the string representation of the package.- Overrides:
toStringin classjava.lang.Object- Returns:
- String representation of the package.
-
-