to top
public interface

IHttpHelper

com.android.tradefed.util.net.IHttpHelper
Known Indirect Subclasses

Class Overview

Helper methods for performing http requests.

Summary

Nested Classes
class IHttpHelper.DataSizeException  
Constants
int MAX_DATA_SIZE
Public Methods
abstract String buildParameters(MultiMap<String, String> paramMap)
Build the encoded parameter string.
abstract String buildUrl(String url, MultiMap<String, String> paramMap)
Build the full encoded URL request string.
abstract HttpURLConnection createConnection(URL url, String method, String contentType)
Create a to given url.
abstract HttpURLConnection createJsonConnection(URL url, String method)
Creates a connection to given URL for passing json data.
abstract HttpURLConnection createXmlConnection(URL url, String method)
Creates a connection to given URL for passing xml data.
abstract String doGet(String url)
Performs a GET HTTP request method for a given URL and returns it as a String.
abstract void doGetIgnore(String url)
Performs a GET for a given URL, with the given URL parameters ignoring the result.
abstract void doGetIgnoreWithRetry(String url)
Performs {doGetIgnore(String) retrying upon failure.
abstract String doGetWithRetry(String url)
Performs {doGet(String) retrying upon failure.
abstract String doPostWithRetry(String url, String postData, String contentType)
Performs a POST HTTP request method for a given URL and returns it as a String, retrying upon failure.
abstract String doPostWithRetry(String url, String postData)
Performs a POST HTTP request method for a given URL and returns it as a String, retrying upon failure.
abstract int getInitialPollInterval()
Get the initial poll interval in ms.
abstract int getMaxPollInterval()
Get the max poll interval in ms.
abstract int getMaxTime()
Get the maximum time to keep trying the request in ms.
abstract int getOpTimeout()
Get the operation timeout in ms.
abstract void setInitialPollInterval(int time)
Set the initial poll interval in ms.
abstract void setMaxPollInterval(int time)
Set the initial poll interval in ms.
abstract void setMaxTime(int time)
Set the maximum time to keep trying the request in ms.
abstract void setOpTimeout(int time)
Set the operation timeout in ms.

Constants

public static final int MAX_DATA_SIZE

Constant Value: 65536 (0x00010000)

Public Methods

public abstract String buildParameters (MultiMap<String, String> paramMap)

Build the encoded parameter string.

Parameters
paramMap the URL parameters
Returns
  • the encoded parameter string
Throws
IllegalArgumentException if an exception occurs encoding the parameters.

public abstract String buildUrl (String url, MultiMap<String, String> paramMap)

Build the full encoded URL request string.

Parameters
url the base URL
paramMap the URL parameters
Returns
  • the constructed URL
Throws
IllegalArgumentException if an exception occurs encoding the parameters.

public abstract HttpURLConnection createConnection (URL url, String method, String contentType)

Create a to given url.

Parameters
url the URL to connect to.
method the HTTP request method. For example, GET or POST.
contentType the content type. For example, "text/html".
Returns
  • The HttpURLConnection
Throws
IOException if an IOException occurs.

public abstract HttpURLConnection createJsonConnection (URL url, String method)

Creates a connection to given URL for passing json data.

Parameters
url the URL to connect to.
method the HTTP request method. For example, GET or POST.
Returns
Throws
IOException if failed to make connection

public abstract HttpURLConnection createXmlConnection (URL url, String method)

Creates a connection to given URL for passing xml data.

Parameters
url the URL to connect to.
method the HTTP request method. For example, GET or POST.
Returns
Throws
IOException if failed to make connection

public abstract String doGet (String url)

Performs a GET HTTP request method for a given URL and returns it as a String.

Because remote contents are loaded into memory, this method should only be used for relatively small data sizes.

References:

Parameters
url the URL
Returns
Throws
IOException if failed to retrieve data
IHttpHelper.DataSizeException if retrieved data is > MAX_DATA_SIZE

public abstract void doGetIgnore (String url)

Performs a GET for a given URL, with the given URL parameters ignoring the result.

Parameters
url the URL
Throws
IOException if failed to retrieve data
See Also

public abstract void doGetIgnoreWithRetry (String url)

Performs {doGetIgnore(String) retrying upon failure.

Parameters
url the URL
Throws
IOException if failed to retrieve data

public abstract String doGetWithRetry (String url)

Performs {doGet(String) retrying upon failure.

Parameters
url the URL
Returns
Throws
IOException if failed to retrieve data
IHttpHelper.DataSizeException if retrieved data is > MAX_DATA_SIZE

public abstract String doPostWithRetry (String url, String postData, String contentType)

Performs a POST HTTP request method for a given URL and returns it as a String, retrying upon failure.

Because remote contents are loaded into memory, this method should only be used for relatively small data sizes.

Parameters
url the URL
postData the data to be posted once the connection is open
contentType the content type. For example, "text/html".
Returns
Throws
IOException if failed to retrieve data
IHttpHelper.DataSizeException if retrieved data is > MAX_DATA_SIZE

public abstract String doPostWithRetry (String url, String postData)

Performs a POST HTTP request method for a given URL and returns it as a String, retrying upon failure.

Because remote contents are loaded into memory, this method should only be used for relatively small data sizes.

Parameters
url the URL
postData the data to be posted once the connection is open
Returns
Throws
IOException if failed to retrieve data
IHttpHelper.DataSizeException if retrieved data is > MAX_DATA_SIZE

public abstract int getInitialPollInterval ()

public abstract int getMaxPollInterval ()

public abstract int getMaxTime ()

Get the maximum time to keep trying the request in ms.

public abstract int getOpTimeout ()

public abstract void setInitialPollInterval (int time)

public abstract void setMaxPollInterval (int time)

public abstract void setMaxTime (int time)

Set the maximum time to keep trying the request in ms.

public abstract void setOpTimeout (int time)