Skip to content

Commit 55c7128

Browse files
committed
Merge pull request android-async-http#129 from jlopez/master
Minor changes to a great library
2 parents c7c3f85 + ebaeff5 commit 55c7128

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/com/loopj/android/http/AsyncHttpClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ private void sendRequest(DefaultHttpClient client, HttpContext httpContext, Http
569569
}
570570
}
571571

572-
private String getUrlWithQueryString(String url, RequestParams params) {
572+
public static String getUrlWithQueryString(String url, RequestParams params) {
573573
if(params != null) {
574574
String paramString = params.getParamString();
575575
url += "?" + paramString;

src/com/loopj/android/http/BinaryHttpResponseHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public void onSuccess(int statusCode, byte[] binaryData) {
100100
* Fired when a request fails to complete, override to handle in your own code
101101
* @param error the underlying cause of the failure
102102
* @param binaryData the response body, if any
103+
* @deprecated
103104
*/
104105
public void onFailure(Throwable error, byte[] binaryData) {
105106
// By default, call the deprecated onFailure(Throwable) for compatibility

src/com/loopj/android/http/RequestParams.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@ public RequestParams(String key, String value) {
9090
put(key, value);
9191
}
9292

93+
/**
94+
* Constructs a new RequestParams instance and populate it with multiple
95+
* initial key/value string param.
96+
* @param keysAndValues a sequence of keys and values. Objects are
97+
* automatically converted to Strings (including the value {@code null}).
98+
* @throws IllegalArgumentException if the number of arguments isn't even.
99+
*/
100+
public RequestParams(Object... keysAndValues) {
101+
int len = keysAndValues.length;
102+
if (len % 2 != 0)
103+
throw new IllegalArgumentException("Supplied arguments must be even");
104+
for (int i = 0; i < len; i += 2) {
105+
String key = String.valueOf(keysAndValues[i]);
106+
String val = String.valueOf(keysAndValues[i + 1]);
107+
put(key, val);
108+
}
109+
}
110+
93111
/**
94112
* Adds a key/value string pair to the request.
95113
* @param key the key name for the new param.

0 commit comments

Comments
 (0)