/** * Perform a HTTP DELETE request. * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param responseHandler the response handler instance that should handle the response. */ public void delete(Context context, String url, AsyncHttpResponseHandler responseHandler) { final HttpDelete delete = new HttpDelete(url); sendRequest(httpClient, httpContext, delete, null, responseHandler, context); }
/** * Perform getUrl HTTP DELETE request. * * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param responseHandler the response handler instance that should handle the response. * @return RequestHandle of future request process */ public RequestHandle delete(Context context, String url, ResponseHandlerInterface responseHandler) { final HttpDelete delete = new HttpDelete(URI.create(url).normalize()); return sendRequest(httpClient, httpContext, delete, null, responseHandler, context); }
/** * Perform a HTTP PUT request and track the Android Context which initiated the request. * And set one-time headers for the request * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param entity a raw {@link HttpEntity} to send with the request, for example, use this to send string/json/xml payloads to a server by passing a {@link org.apache.http.entity.StringEntity}. * @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 put(Context context, String url, HttpEntity entity, String contentType, AsyncHttpResponseHandler responseHandler) { sendRequest(httpClient, httpContext, addEntityToRequestBase(new HttpPut(url), entity), contentType, responseHandler, context); }
/** * Perform getUrl HTTP GET request and track the Android Context which initiated the request. * * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param params additional GET parameters to send with the request. * @param responseHandler the response handler instance that should handle the response. * @return RequestHandle of future request process */ public RequestHandle get(Context context, String url, RequestParams params, ResponseHandlerInterface responseHandler) { return sendRequest(httpClient, httpContext, new HttpGet(getUrlWithQueryString(isUrlEncodingEnabled, url, params)), null, responseHandler, context); }
/** * Perform getUrl HTTP HEAD request and track the Android Context which initiated the request. * * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param params additional HEAD parameters to send with the request. * @param responseHandler the response handler instance that should handle the response. * @return RequestHandle of future request process */ public RequestHandle head(Context context, String url, RequestParams params, ResponseHandlerInterface responseHandler) { return sendRequest(httpClient, httpContext, new HttpHead(getUrlWithQueryString(isUrlEncodingEnabled, url, params)), null, responseHandler, context); }
/** * Perform a HTTP GET request and track the Android Context which initiated the request. * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param params additional GET parameters to send with the request. * @param responseHandler the response handler instance that should handle the response. */ public void get(Context context, String url, RequestParams params, AsyncHttpResponseHandler responseHandler) { sendRequest(httpClient, httpContext, new HttpGet(getUrlWithQueryString(url, params)), null, responseHandler, context); }
/** * Perform a HTTP DELETE request. * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param headers set one-time headers for this request * @param responseHandler the response handler instance that should handle the response. */ public void delete(Context context, String url, Header[] headers, AsyncHttpResponseHandler responseHandler) { final HttpDelete delete = new HttpDelete(url); if(headers != null) delete.setHeaders(headers); sendRequest(httpClient, httpContext, delete, null, responseHandler, context); }
/** * Perform a HTTP POST request and track the Android Context which initiated the request. * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param entity a raw {@link HttpEntity} to send with the request, for example, use this to send string/json/xml payloads to a server by passing a {@link org.apache.http.entity.StringEntity}. * @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, HttpEntity entity, String contentType, AsyncHttpResponseHandler responseHandler) { sendRequest(httpClient, httpContext, addEntityToRequestBase(new HttpPost(url), entity), contentType, responseHandler, context); }
/** * Perform getUrl HTTP DELETE request. * * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param headers set one-time headers for this request * @param responseHandler the response handler instance that should handle the response. * @return RequestHandle of future request process */ public RequestHandle delete(Context context, String url, Header[] headers, ResponseHandlerInterface responseHandler) { final HttpDelete delete = new HttpDelete(URI.create(url).normalize()); if (headers != null) delete.setHeaders(headers); return sendRequest(httpClient, httpContext, delete, null, responseHandler, context); }
/** * Perform getUrl HTTP POST request and track the Android Context which initiated the request. * * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param entity getUrl raw {@link HttpEntity} to send with the request, for * example, use this to send string/json/xml payloads to getUrl server by * passing getUrl {@link org.apache.http.entity.StringEntity}. * @param contentType the content type of the payload you are sending, for example * application/json if sending getUrl json payload. * @param responseHandler the response ha ndler instance that should handle the response. * @return RequestHandle of future request process */ public RequestHandle post(Context context, String url, HttpEntity entity, String contentType, ResponseHandlerInterface responseHandler) { return sendRequest(httpClient, httpContext, addEntityToRequestBase(new HttpPost(URI.create(url).normalize()), entity), contentType, responseHandler, context); }
/** * Perform getUrl HTTP PUT request and track the Android Context which initiated the request. And set * one-time headers for the request * * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param entity getUrl raw {@link HttpEntity} to send with the request, for example, use * this to send string/json/xml payloads to getUrl server by passing getUrl {@link * org.apache.http.entity.StringEntity}. * @param contentType the content type of the payload you are sending, for example * application/json if sending getUrl json payload. * @param responseHandler the response handler instance that should handle the response. * @return RequestHandle of future request process */ public RequestHandle put(Context context, String url, HttpEntity entity, String contentType, ResponseHandlerInterface responseHandler) { return sendRequest(httpClient, httpContext, addEntityToRequestBase(new HttpPut(URI.create(url).normalize()), entity), contentType, responseHandler, context); }
/** * Perform getUrl HTTP DELETE request. * * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param headers set one-time headers for this request * @param params additional DELETE parameters or files to send along with request * @param responseHandler the response handler instance that should handle the response. * @return RequestHandle of future request process */ public RequestHandle delete(Context context, String url, Header[] headers, RequestParams params, ResponseHandlerInterface responseHandler) { HttpDelete httpDelete = new HttpDelete(getUrlWithQueryString(isUrlEncodingEnabled, url, params)); if (headers != null) httpDelete.setHeaders(headers); return sendRequest(httpClient, httpContext, httpDelete, null, responseHandler, context); }
/** * Perform getUrl 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 getUrl json payload. * @param responseHandler the response handler instance that should handle the response. * @return RequestHandle of future request process */ public RequestHandle post(Context context, String url, Header[] headers, RequestParams params, String contentType, ResponseHandlerInterface responseHandler) { HttpEntityEnclosingRequestBase request = new HttpPost(URI.create(url).normalize()); if (params != null) request.setEntity(paramsToEntity(params, responseHandler)); if (headers != null) request.setHeaders(headers); return sendRequest(httpClient, httpContext, request, contentType, responseHandler, context); }
/** * Perform a HTTP PUT request and track the Android Context which initiated the request. * And set one-time headers for the request * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param headers set one-time headers for this request * @param entity a raw {@link HttpEntity} to send with the request, for example, use this to send string/json/xml payloads to a server by passing a {@link org.apache.http.entity.StringEntity}. * @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 put(Context context, String url,Header[] headers, HttpEntity entity, String contentType, AsyncHttpResponseHandler responseHandler) { HttpEntityEnclosingRequestBase request = addEntityToRequestBase(new HttpPut(url), entity); if(headers != null) request.setHeaders(headers); sendRequest(httpClient, httpContext, request, contentType, responseHandler, context); }
/** * Perform getUrl HTTP PUT request and track the Android Context which initiated the request. And set * one-time headers for the request * * @param context the Android Context which initiated the request. * @param url the URL to send the request to. * @param headers set one-time headers for this request * @param entity getUrl raw {@link HttpEntity} to send with the request, for example, use * this to send string/json/xml payloads to getUrl server by passing getUrl {@link * org.apache.http.entity.StringEntity}. * @param contentType the content type of the payload you are sending, for example * application/json if sending getUrl json payload. * @param responseHandler the response handler instance that should handle the response. * @return RequestHandle of future request process */ public RequestHandle put(Context context, String url, Header[] headers, HttpEntity entity, String contentType, ResponseHandlerInterface responseHandler) { HttpEntityEnclosingRequestBase request = addEntityToRequestBase(new HttpPut(URI.create(url).normalize()), entity); if (headers != null) request.setHeaders(headers); return sendRequest(httpClient, httpContext, request, contentType, responseHandler, context); }
/** * Perform getUrl HTTP GET request and track the Android Context which initiated the request with * customized headers * * @param context Context to execute request against * @param url the URL to send the request to. * @param headers set headers only for this request * @param params additional GET parameters to send with the request. * @param responseHandler the response handler instance that should handle the response. * @return RequestHandle of future request process */ public RequestHandle get(Context context, String url, Header[] headers, RequestParams params, ResponseHandlerInterface responseHandler) { HttpUriRequest request = new HttpGet(getUrlWithQueryString(isUrlEncodingEnabled, url, params)); if (headers != null) request.setHeaders(headers); return sendRequest(httpClient, httpContext, request, null, responseHandler, context); }
/** * Perform a HTTP GET request and track the Android Context which initiated * the request with customized headers * * @param url the URL to send the request to. * @param headers set headers only for this request * @param params additional GET parameters to send with the request. * @param responseHandler the response handler instance that should handle * the response. */ public void get(Context context, String url, Header[] headers, RequestParams params, AsyncHttpResponseHandler responseHandler) { HttpUriRequest request = new HttpGet(getUrlWithQueryString(url, params)); if(headers != null) request.setHeaders(headers); sendRequest(httpClient, httpContext, request, null, responseHandler, context); }
/** * Perform getUrl HTTP HEAD request and track the Android Context which initiated the request with * customized headers * * @param context Context to execute request against * @param url the URL to send the request to. * @param headers set headers only for this request * @param params additional HEAD parameters to send with the request. * @param responseHandler the response handler instance that should handle the response. * @return RequestHandle of future request process */ public RequestHandle head(Context context, String url, Header[] headers, RequestParams params, ResponseHandlerInterface responseHandler) { HttpUriRequest request = new HttpHead(getUrlWithQueryString(isUrlEncodingEnabled, url, params)); if (headers != null) request.setHeaders(headers); return sendRequest(httpClient, httpContext, request, null, responseHandler, context); }
/** * 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 entity a raw {@link HttpEntity} to send with the request, for * example, use this to send string/json/xml payloads to a server by * passing a {@link org.apache.http.entity.StringEntity}. * @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, HttpEntity entity, String contentType, AsyncHttpResponseHandler responseHandler) { HttpEntityEnclosingRequestBase request = addEntityToRequestBase(new HttpPost(url), entity); if(headers != null) request.setHeaders(headers); sendRequest(httpClient, httpContext, request, contentType, responseHandler, context); }
@Override protected RequestHandle sendRequest( cz.msebera.android.httpclient.impl.client.DefaultHttpClient client, cz.msebera.android.httpclient.protocol.HttpContext httpContext, cz.msebera.android.httpclient.client.methods.HttpUriRequest uriRequest, String contentType, ResponseHandlerInterface responseHandler, Context context) { if (this.service != null && accessToken != null) { try { ScribeRequestAdapter adapter = new ScribeRequestAdapter(uriRequest); this.service.signRequest(accessToken, adapter); return super.sendRequest(client, httpContext, uriRequest, contentType, responseHandler, context); } catch (Exception e) { e.printStackTrace(); } } else if (accessToken == null) { throw new OAuthException("Cannot send unauthenticated requests for " + apiInstance.getClass().getSimpleName() + " client. Please attach an access token!"); } else { // service is null throw new OAuthException("Cannot send unauthenticated requests for undefined service. Please specify a valid api service!"); } return null; // Hopefully never reaches here }