Class Request


  • public class Request
    extends Object
    Represents a network request being managed by the Comm Framework.

    Author:
    Todd S. Murchison
    • Constructor Detail

      • Request

        protected Request​(URI uri,
                          Request.RequestMethod method,
                          byte[] postData,
                          Map<String,​String> headers,
                          boolean isIdempotent)
        Creates an instance of Request.

        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 - A Map of 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

      • getPostData

        public byte[] getPostData()
        Returns the POST data of this Request instance or null if there is no POST data.
      • getHeaders

        public Map<String,​String> getHeaders()
        Returns the headers of this Request instance 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.
      • getUri

        public URI getUri()
        Returns the most recent URI to be used for this Request instance.
      • redirect

        protected boolean redirect​(URI newLocation)
        If the given URI has never been visited before for this Request instance this method updates the URI end-point of this request to the given new location and returns true. If this Request instance 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 times redirect(URI) has been called on this Request instance.
      • getId

        public int getId()
        The ID of this Request. 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 this Request. 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.
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(Object request)
        Returns TRUE if this Request instance is equivalent to the given Request instance. Requests are considered equal if their URLs are the same, regardless of parameter order, and their POST bodies are the same.
        Overrides:
        equals in class Object