Skip to content

Commit 483b562

Browse files
committed
allow empty POST bodies
1 parent add5b9d commit 483b562

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

example/src/main/java/com/codepath/example/TestActivity.java

+14-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,20 @@ public void onFailure(int statusCode, Headers headers, String response, Throwabl
4949
}
5050
});
5151

52-
cp.post("https://api.thecatapi.com/v1/images/search", "", new JsonHttpResponseHandler() {
52+
cp.post("https://api.thecatapi.com/v1/images/search", new JsonHttpResponseHandler() {
53+
@Override
54+
public void onSuccess(int statusCode, Headers headers, JSON json) {
55+
Log.d("DEBUG", json.toString());
56+
57+
}
58+
59+
@Override
60+
public void onFailure(int statusCode, Headers headers, String response, Throwable throwable) {
61+
62+
}
63+
});
64+
65+
cp.post("https://api.thecatapi.com/v1/images/search", "test", new JsonHttpResponseHandler() {
5366
@Override
5467
public void onSuccess(int statusCode, Headers headers, JSON json) {
5568
Log.d("DEBUG", json.toString());

library/src/main/java/com/codepath/asynchttpclient/AsyncHttpClient.java

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ public void post(String url, RequestParams requestParams, RequestHeaders request
8686
okHttpClient.newCall(request).enqueue(callback);
8787
}
8888

89+
public void post(String url, AbsCallback callback) {
90+
this.post(url, null, null, "", callback);
91+
}
92+
8993
public void post(String url, String body, AbsCallback callback) {
9094
this.post(url, null, null, body, callback);
9195
}

0 commit comments

Comments
 (0)