com.loopj.android.http
Class RequestParams

java.lang.Object
  extended by com.loopj.android.http.RequestParams

public class RequestParams
extends Object

A collection of string request parameters or files to send along with requests made from an AsyncHttpClient instance.

For example:

 RequestParams params = new RequestParams();
 params.put("username", "james");
 params.put("password", "123456");
 params.put("email", "my@email.com");
 params.put("profile_picture", new File("pic.jpg")); // Upload a File
 params.put("profile_picture2", someInputStream); // Upload an InputStream
 params.put("profile_picture3", new ByteArrayInputStream(someBytes)); // Upload some bytes

 AsyncHttpClient client = new AsyncHttpClient();
 client.post("http://myendpoint.com", params, responseHandler);
 


Field Summary
protected  ConcurrentHashMap<String,com.loopj.android.http.RequestParams.FileWrapper> fileParams
           
protected  ConcurrentHashMap<String,String> urlParams
           
 
Constructor Summary
RequestParams()
          Constructs a new empty RequestParams instance.
RequestParams(Map<String,String> source)
          Constructs a new RequestParams instance containing the key/value string params from the specified map.
RequestParams(String key, String value)
          Constructs a new RequestParams instance and populate it with a single initial key/value string param.
 
Method Summary
 void put(String key, File file)
          Adds a file to the request.
 void put(String key, InputStream stream)
          Adds an input stream to the request.
 void put(String key, InputStream stream, String fileName)
          Adds an input stream to the request.
 void put(String key, InputStream stream, String fileName, String contentType)
          Adds an input stream to the request.
 void put(String key, String value)
          Adds a key/value string pair to the request.
 void remove(String key)
          Removes a parameter from the request.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

urlParams

protected ConcurrentHashMap<String,String> urlParams

fileParams

protected ConcurrentHashMap<String,com.loopj.android.http.RequestParams.FileWrapper> fileParams
Constructor Detail

RequestParams

public RequestParams()
Constructs a new empty RequestParams instance.


RequestParams

public RequestParams(Map<String,String> source)
Constructs a new RequestParams instance containing the key/value string params from the specified map.

Parameters:
source - the source key/value string map to add.

RequestParams

public RequestParams(String key,
                     String value)
Constructs a new RequestParams instance and populate it with a single initial key/value string param.

Parameters:
key - the key name for the intial param.
value - the value string for the initial param.
Method Detail

put

public void put(String key,
                String value)
Adds a key/value string pair to the request.

Parameters:
key - the key name for the new param.
value - the value string for the new param.

put

public void put(String key,
                File file)
         throws FileNotFoundException
Adds a file to the request.

Parameters:
key - the key name for the new param.
file - the file to add.
Throws:
FileNotFoundException

put

public void put(String key,
                InputStream stream)
Adds an input stream to the request.

Parameters:
key - the key name for the new param.
stream - the input stream to add.

put

public void put(String key,
                InputStream stream,
                String fileName)
Adds an input stream to the request.

Parameters:
key - the key name for the new param.
stream - the input stream to add.
fileName - the name of the file.

put

public void put(String key,
                InputStream stream,
                String fileName,
                String contentType)
Adds an input stream to the request.

Parameters:
key - the key name for the new param.
stream - the input stream to add.
fileName - the name of the file.
contentType - the content type of the file, eg. application/json

remove

public void remove(String key)
Removes a parameter from the request.

Parameters:
key - the key name for the parameter to remove.

toString

public String toString()
Overrides:
toString in class Object