Build 1.0_r1(from source)

android.net.http
Class Request

java.lang.Object
  extended by android.net.http.Request

 class Request
extends Object

Represents an HTTP request for a given host.


Field Summary
(package private)  boolean mCancelled
          True if request has been cancelled
(package private)  EventHandler mEventHandler
          The eventhandler to call as the request progresses
(package private)  int mFailCount
           
(package private)  boolean mHighPriority
          True if request is .html, .js, .css
(package private)  HttpHost mHost
          Host serving this request
(package private)  BasicHttpRequest mHttpRequest
          The Apache http request
(package private)  String mPath
          The path component of this request
(package private)  HttpHost mProxyHost
          Set if I'm using a proxy server
 
Constructor Summary
Request(String method, HttpHost host, HttpHost proxyHost, String path, InputStream bodyProvider, int bodyLength, EventHandler eventHandler, Map<String,String> headers, boolean highPriority)
          Instantiates a new Request.
 
Method Summary
(package private)  void addHeader(String name, String value)
          Add header represented by given pair to request.
(package private)  void addHeaders(Map<String,String> headers)
          Add all headers in given map to this request.
(package private)  void cancel()
          Data will not be sent to or received from server after cancel() call.
(package private)  void complete()
           
(package private)  void error(int errorId, int resourceId)
          Helper: calls error() on eventhandler with appropriate message This should not be called before the mConnection is set.
(package private)  EventHandler getEventHandler()
           
(package private)  String getHostPort()
           
(package private)  String getUri()
           
 void handleSslErrorResponse(boolean proceed)
          Handles SSL error(s) on the way down from the user (the user has already provided their feedback).
(package private)  void readResponse(AndroidHttpClientConnection httpClientConnection)
          Receive a single http response.
(package private)  void reset()
          If this request has been sent once and failed, it must be reset before it can be sent again.
(package private)  void sendRequest(AndroidHttpClientConnection httpClientConnection)
          Send the request line and headers
(package private)  void setConnection(Connection connection)
           
 String toString()
          for debugging
(package private)  void waitUntilComplete()
          Pause thread request completes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mEventHandler

EventHandler mEventHandler
The eventhandler to call as the request progresses


mHttpRequest

BasicHttpRequest mHttpRequest
The Apache http request


mPath

String mPath
The path component of this request


mHost

HttpHost mHost
Host serving this request


mProxyHost

HttpHost mProxyHost
Set if I'm using a proxy server


mHighPriority

boolean mHighPriority
True if request is .html, .js, .css


mCancelled

volatile boolean mCancelled
True if request has been cancelled


mFailCount

int mFailCount
Constructor Detail

Request

Request(String method,
        HttpHost host,
        HttpHost proxyHost,
        String path,
        InputStream bodyProvider,
        int bodyLength,
        EventHandler eventHandler,
        Map<String,String> headers,
        boolean highPriority)
Instantiates a new Request.

Parameters:
method - GET/POST/PUT
host - The server that will handle this request
path - path part of URI
bodyProvider - InputStream providing HTTP body, null if none
bodyLength - length of body, must be 0 if bodyProvider is null
eventHandler - request will make progress callbacks on this interface
headers - reqeust headers
highPriority - true for .html, css, .cs
Method Detail

setConnection

void setConnection(Connection connection)
Parameters:
connection - Request served by this connection

getEventHandler

EventHandler getEventHandler()

addHeader

void addHeader(String name,
               String value)
Add header represented by given pair to request. Header will be formatted in request as "name: value\r\n".

Parameters:
name - of header
value - of header

addHeaders

void addHeaders(Map<String,String> headers)
Add all headers in given map to this request. This is a helper method: it calls addHeader for each pair in the map.


sendRequest

void sendRequest(AndroidHttpClientConnection httpClientConnection)
           throws HttpException,
                  IOException
Send the request line and headers

Throws:
HttpException
IOException

readResponse

void readResponse(AndroidHttpClientConnection httpClientConnection)
            throws IOException,
                   ParseException
Receive a single http response.

Parameters:
httpClientConnection - the request to receive the response for.
Throws:
IOException
ParseException

cancel

void cancel()
Data will not be sent to or received from server after cancel() call. Does not close connection--use close() below for that. Called by RequestHandle from non-network thread


getHostPort

String getHostPort()

getUri

String getUri()

toString

public String toString()
for debugging

Overrides:
toString in class Object
Returns:
String a printable representation for the receiver.

reset

void reset()
If this request has been sent once and failed, it must be reset before it can be sent again.


waitUntilComplete

void waitUntilComplete()
Pause thread request completes. Used for synchronous requests, and testing


complete

void complete()

handleSslErrorResponse

public void handleSslErrorResponse(boolean proceed)
Handles SSL error(s) on the way down from the user (the user has already provided their feedback).


error

void error(int errorId,
           int resourceId)
Helper: calls error() on eventhandler with appropriate message This should not be called before the mConnection is set.


Build 1.0_r1(from source)

Please submit a feedback, bug or feature