Skip to content

Commit 9072890

Browse files
committed
Support for alternative post entities other than key value pairs
1 parent 0b77d22 commit 9072890

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<project default="package">
22
<!-- Project properties -->
3-
<property name="version.num" value="1.2.0" />
3+
<property name="version.num" value="1.2.1" />
44
<property name="project" value="android-async-http" />
55

66
<!-- Standard jar stuff -->

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,24 @@ public void post(String url, RequestParams params, AsyncHttpResponseHandler resp
172172
}
173173

174174
public void post(Context context, String url, RequestParams params, AsyncHttpResponseHandler responseHandler) {
175+
HttpEntity entity = null;
176+
if(params != null) {
177+
entity = params.getEntity();
178+
}
179+
180+
post(context, url, entity, null, responseHandler);
181+
}
182+
183+
public void post(Context context, String url, HttpEntity entity, String contentType, AsyncHttpResponseHandler responseHandler) {
175184
// Build post object with params
176185
final HttpPost post = new HttpPost(url);
177-
if(params != null) {
178-
HttpEntity entity = params.getEntity();
179-
if(entity != null){
180-
post.setEntity(entity);
181-
}
186+
187+
if(entity != null){
188+
post.setEntity(entity);
189+
}
190+
191+
if(contentType != null) {
192+
post.addHeader("Content-Type", contentType);
182193
}
183194

184195
// Fire up the request in a new thread

0 commit comments

Comments
 (0)