com.github.ignition.support.http
Interface IgnitedHttpRequest

All Known Implementing Classes:
CachedHttpRequest, IgnitedHttpRequestBase

public interface IgnitedHttpRequest


Method Summary
 IgnitedHttpRequest expecting(Integer... statusCodes)
          Define the set of HTTP status codes which you anticipate to be returned by the server, including error codes you'd like to explicitly handle.
 String getRequestUrl()
           
 IgnitedHttpRequest retries(int retries)
          Set maximum number of retries for this particular request.
 IgnitedHttpResponse send()
          Sends the current request.
 org.apache.http.client.methods.HttpUriRequest unwrap()
           
 IgnitedHttpRequest withTimeout(int timeout)
          Set the global timeout for this specific request (connection and socket timeout).
 

Method Detail

unwrap

org.apache.http.client.methods.HttpUriRequest unwrap()
Returns:
the HttpClient request object wrapped by this request

getRequestUrl

String getRequestUrl()
Returns:
the request URL

expecting

IgnitedHttpRequest expecting(Integer... statusCodes)
Define the set of HTTP status codes which you anticipate to be returned by the server, including error codes you'd like to explicitly handle. Any status code part of this set will not be treated as an error, but returned to you as a normal server response. Any status codes returned by the server that are not part of this set will be raised as an HttpResponseException. This is very useful when dealing with REST-ful Web services, where it is common to serve error stati that indicate a failure in the application logic (e.g. 404 if a resource doesn't exist). You typically don't want to treat those as connection errors, but gracefully handle them like a normal success code.

Parameters:
statusCodes - the set of status codes that you want to manually handle as part of the response
Returns:
this request

retries

IgnitedHttpRequest retries(int retries)
Set maximum number of retries for this particular request.

Parameters:
retries - the maximum number of retries should the request fail
Returns:
this request

withTimeout

IgnitedHttpRequest withTimeout(int timeout)
Set the global timeout for this specific request (connection and socket timeout).

Parameters:
timeout - the timeout in milliseconds
Returns:
this request

send

IgnitedHttpResponse send()
                         throws ConnectException
Sends the current request. This method uses a special retry-logic (on top of that employed by HttpClient, which is better suited to handle network fail-overs when e.g. switching between Wi-Fi and 3G).

Throws:
ConnectException


Copyright © 2012. All Rights Reserved.