Skip to content

Commit a1703ae

Browse files
committed
Merge pull request android-async-http#76 from mdelaneyaz/master
Added POST method to take HttpEntity
2 parents cff7425 + a568241 commit a1703ae

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,7 @@ public void post(Context context, String url, HttpEntity entity, String contentT
409409
* @param context the Android Context which initiated the request.
410410
* @param url the URL to send the request to.
411411
* @param headers set headers only for this request
412-
* @param entity a raw {@link HttpEntity} to send with the request, for
413-
* example, use this to send string/json/xml payloads to a server by
414-
* passing a {@link org.apache.http.entity.StringEntity}.
412+
* @param params additional POST parameters to send with the request.
415413
* @param contentType the content type of the payload you are sending, for
416414
* example application/json if sending a json payload.
417415
* @param responseHandler the response handler instance that should handle
@@ -426,6 +424,28 @@ public void post(Context context, String url, Header[] headers, RequestParams pa
426424
responseHandler, context);
427425
}
428426

427+
/**
428+
* Perform a HTTP POST request and track the Android Context which initiated
429+
* the request. Set headers only for this request
430+
*
431+
* @param context the Android Context which initiated the request.
432+
* @param url the URL to send the request to.
433+
* @param headers set headers only for this request
434+
* @param entity a raw {@link HttpEntity} to send with the request, for
435+
* example, use this to send string/json/xml payloads to a server by
436+
* passing a {@link org.apache.http.entity.StringEntity}.
437+
* @param contentType the content type of the payload you are sending, for
438+
* example application/json if sending a json payload.
439+
* @param responseHandler the response handler instance that should handle
440+
* the response.
441+
*/
442+
public void post(Context context, String url, Header[] headers, HttpEntity entity, String contentType,
443+
AsyncHttpResponseHandler responseHandler) {
444+
HttpEntityEnclosingRequestBase request = addEntityToRequestBase(new HttpPost(url), entity);
445+
if(headers != null) request.setHeaders(headers);
446+
sendRequest(httpClient, httpContext, request, contentType, responseHandler, context);
447+
}
448+
429449
//
430450
// HTTP PUT Requests
431451
//

0 commit comments

Comments
 (0)