private HttpEntityEnclosingRequestBase addEntityToRequestBase( HttpEntityEnclosingRequestBase requestBase, HttpEntity entity) { if (entity != null) { requestBase.setEntity(entity); } return requestBase; }
/** * Perform a HTTP POST request and track the Android Context which initiated the request. Set * headers only for this request * * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param headers set headers only for this request * @param params additional POST parameters to send with the request. * @param contentType the content type of the payload you are sending, for example * application/json if sending a json payload. * @param responseHandler the response handler instance that should handle the response. */ public void post( Context context, String url, Header[] headers, RequestParams params, String contentType, AsyncHttpResponseHandler responseHandler) { HttpEntityEnclosingRequestBase request = new HttpPost(url); if (params != null) request.setEntity(paramsToEntity(params)); if (headers != null) request.setHeaders(headers); sendRequest(cachingHttpClient, httpContext, request, contentType, responseHandler, context); }