|
35 | 35 | import org.apache.http.client.methods.HttpDelete;
|
36 | 36 | import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
37 | 37 | import org.apache.http.client.methods.HttpGet;
|
| 38 | +import org.apache.http.client.methods.HttpHead; |
38 | 39 | import org.apache.http.client.methods.HttpPost;
|
39 | 40 | import org.apache.http.client.methods.HttpPut;
|
40 | 41 | import org.apache.http.client.methods.HttpUriRequest;
|
@@ -302,6 +303,67 @@ public void cancelRequests(Context context, boolean mayInterruptIfRunning) {
|
302 | 303 | requestMap.remove(context);
|
303 | 304 | }
|
304 | 305 |
|
| 306 | + // |
| 307 | + // HTTP HEAD Requests |
| 308 | + // |
| 309 | + |
| 310 | + /** |
| 311 | + * Perform a HTTP HEAD request, without any parameters. |
| 312 | + * @param url the URL to send the request to. |
| 313 | + * @param responseHandler the response handler instance that should handle the response. |
| 314 | + */ |
| 315 | + public void head(String url, AsyncHttpResponseHandler responseHandler) { |
| 316 | + head(null, url, null, responseHandler); |
| 317 | + } |
| 318 | + |
| 319 | + /** |
| 320 | + * Perform a HTTP HEAD request with parameters. |
| 321 | + * @param url the URL to send the request to. |
| 322 | + * @param params additional HEAD parameters to send with the request. |
| 323 | + * @param responseHandler the response handler instance that should handle the response. |
| 324 | + */ |
| 325 | + public void head(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) { |
| 326 | + head(null, url, params, responseHandler); |
| 327 | + } |
| 328 | + |
| 329 | + /** |
| 330 | + * Perform a HTTP HEAD request without any parameters and track the Android Context which initiated the request. |
| 331 | + * @param context the Android Context which initiated the request. |
| 332 | + * @param url the URL to send the request to. |
| 333 | + * @param responseHandler the response handler instance that should handle the response. |
| 334 | + */ |
| 335 | + public void head(Context context, String url, AsyncHttpResponseHandler responseHandler) { |
| 336 | + head(context, url, null, responseHandler); |
| 337 | + } |
| 338 | + |
| 339 | + /** |
| 340 | + * Perform a HTTP HEAD request and track the Android Context which initiated the request. |
| 341 | + * @param context the Android Context which initiated the request. |
| 342 | + * @param url the URL to send the request to. |
| 343 | + * @param params additional HEAD parameters to send with the request. |
| 344 | + * @param responseHandler the response handler instance that should handle the response. |
| 345 | + */ |
| 346 | + public void head(Context context, String url, RequestParams params, AsyncHttpResponseHandler responseHandler) { |
| 347 | + sendRequest(httpClient, httpContext, new HttpHead(getUrlWithQueryString(url, params)), null, responseHandler, context); |
| 348 | + } |
| 349 | + |
| 350 | + /** |
| 351 | + * Perform a HTTP HEAD request and track the Android Context which initiated |
| 352 | + * the request with customized headers |
| 353 | + * |
| 354 | + * @param url the URL to send the request to. |
| 355 | + * @param headers set headers only for this request |
| 356 | + * @param params additional HEAD parameters to send with the request. |
| 357 | + * @param responseHandler the response handler instance that should handle |
| 358 | + * the response. |
| 359 | + */ |
| 360 | + public void head(Context context, String url, Header[] headers, RequestParams params, AsyncHttpResponseHandler responseHandler) { |
| 361 | + HttpUriRequest request = new HttpHead(getUrlWithQueryString(url, params)); |
| 362 | + if(headers != null) request.setHeaders(headers); |
| 363 | + sendRequest(httpClient, httpContext, request, null, responseHandler, |
| 364 | + context); |
| 365 | + } |
| 366 | + |
305 | 367 |
|
306 | 368 | //
|
307 | 369 | // HTTP GET Requests
|
|
0 commit comments