com.duowan.mobile.netroid.stack
Class HttpClientStack

java.lang.Object
  extended by com.duowan.mobile.netroid.stack.HttpClientStack
All Implemented Interfaces:
HttpStack

public class HttpClientStack
extends java.lang.Object
implements HttpStack

An HttpStack that performs request over an HttpClient.


Nested Class Summary
static class HttpClientStack.HttpPatch
          The HttpPatch class does not exist in the Android framework, so this has been defined here.
 
Field Summary
protected  org.apache.http.client.HttpClient mClient
           
 
Constructor Summary
HttpClientStack(org.apache.http.client.HttpClient client)
           
HttpClientStack(java.lang.String userAgent)
           
 
Method Summary
protected  void onPrepareRequest(org.apache.http.client.methods.HttpUriRequest request)
          Called before the request is executed using the underlying HttpClient.
 org.apache.http.HttpResponse performRequest(Request<?> request)
          Performs an HTTP request with the given parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mClient

protected final org.apache.http.client.HttpClient mClient
Constructor Detail

HttpClientStack

public HttpClientStack(java.lang.String userAgent)

HttpClientStack

public HttpClientStack(org.apache.http.client.HttpClient client)
Method Detail

performRequest

public org.apache.http.HttpResponse performRequest(Request<?> request)
                                            throws java.io.IOException,
                                                   AuthFailureError
Description copied from interface: HttpStack
Performs an HTTP request with the given parameters.

A GET request is sent if request.getPostBody() == null. A POST request is sent otherwise, and the Content-Type header is set to request.getPostBodyContentType().

Specified by:
performRequest in interface HttpStack
Parameters:
request - the request to perform
Returns:
the HTTP response
Throws:
java.io.IOException
AuthFailureError

onPrepareRequest

protected void onPrepareRequest(org.apache.http.client.methods.HttpUriRequest request)
                         throws java.io.IOException
Called before the request is executed using the underlying HttpClient.

Overwrite in subclasses to augment the request.

Throws:
java.io.IOException