Package net.toddm.comm
Class Request
- java.lang.Object
-
- net.toddm.comm.Request
-
public class Request extends Object
Represents a network request being managed by the Comm Framework.- Author:
- Todd S. Murchison
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRequest.RequestMethodHTTP request methods supported by the comm framework.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object request)Map<String,String>getHeaders()Returns the headers of thisRequestinstance or null if there are none.intgetId()The ID of thisRequest.Request.RequestMethodgetMethod()Returns the HTTP method of thisRequestinstance.byte[]getPostData()Returns the POST data of thisRequestinstance or null if there is no POST data.intgetRedirectCount()Returns the total number of timesredirect(URI)has been called on thisRequestinstance.intgetRetryCountFromFailure()Returns the total number of times this request has been retried due to a failure (socket timeout, etc.).intgetRetryCountFromResponse()Returns the total number of times this request has been retried due to a response (503 response code, etc.).URIgetUri()Returns the most recent URI to be used for thisRequestinstance.inthashCode()The hash code of thisRequest.protected voidincrementRetryCountFromFailure()Increments the count of the total number of times this request has been retried due to a failure (socket timeout, etc.).protected voidincrementRetryCountFromResponse()Increments the count of the total number of times this request has been retried due to a response (503 response code, etc.).booleanisIdempotent()Returns a flag indicating if this request is considered to be an idempotent request.protected booleanredirect(URI newLocation)If the given URI has never been visited before for thisRequestinstance this method updates the URI end-point of this request to the given new location and returns true.
-
-
-
Constructor Detail
-
Request
protected Request(URI uri, Request.RequestMethod method, byte[] postData, Map<String,String> headers, boolean isIdempotent)
Creates an instance ofRequest.- Parameters:
uri- The URI for the resource to request.method- The HTTP method for the request (Request.RequestMethod).postData- OPTIONAL. Can be NULL. A map of data to be sent as the POST body content. The values should NOT yet be encoded.headers- AMapof any HTTP header values that should be sent as part of the request.isIdempotent- A flag indicating if this request is considered to be an idempotent request. Retry policy provider implementations will often not want to retry non-idempotent requests on error.
-
-
Method Detail
-
getMethod
public Request.RequestMethod getMethod()
Returns the HTTP method of thisRequestinstance.
-
getPostData
public byte[] getPostData()
Returns the POST data of thisRequestinstance or null if there is no POST data.
-
getHeaders
public Map<String,String> getHeaders()
Returns the headers of thisRequestinstance or null if there are none.
-
isIdempotent
public boolean isIdempotent()
Returns a flag indicating if this request is considered to be an idempotent request. Retry policy provider implementations will often not want to retry non-idempotent request on error.
-
redirect
protected boolean redirect(URI newLocation)
If the given URI has never been visited before for thisRequestinstance this method updates the URI end-point of this request to the given new location and returns true. If thisRequestinstance has seen the given URI before then nothing is changed and false is returned. This method is intended for redirection support (such as handling of a 302 responses).
-
getRedirectCount
public int getRedirectCount()
Returns the total number of timesredirect(URI)has been called on thisRequestinstance.
-
getId
public int getId()
The ID of thisRequest. Requests have the same ID and are considered equal if their URLs are the same, regardless of parameter order, and their POST bodies are the same.
-
incrementRetryCountFromFailure
protected void incrementRetryCountFromFailure()
Increments the count of the total number of times this request has been retried due to a failure (socket timeout, etc.).
-
incrementRetryCountFromResponse
protected void incrementRetryCountFromResponse()
Increments the count of the total number of times this request has been retried due to a response (503 response code, etc.).
-
getRetryCountFromFailure
public int getRetryCountFromFailure()
Returns the total number of times this request has been retried due to a failure (socket timeout, etc.).
-
getRetryCountFromResponse
public int getRetryCountFromResponse()
Returns the total number of times this request has been retried due to a response (503 response code, etc.).
-
hashCode
public int hashCode()
The hash code of thisRequest. Requests have the same hash code and are considered equal if their URLs are the same, regardless of parameter order, and their POST bodies are the same.
-
-