@@ -501,8 +501,8 @@ public void cancelRequests(Context context, boolean mayInterruptIfRunning) {
501
501
* @param url the URL to send the request to.
502
502
* @param responseHandler the response handler instance that should handle the response.
503
503
*/
504
- public void head (String url , AsyncHttpResponseHandler responseHandler ) {
505
- head (null , url , null , responseHandler );
504
+ public RequestHandle head (String url , AsyncHttpResponseHandler responseHandler ) {
505
+ return head (null , url , null , responseHandler );
506
506
}
507
507
508
508
/**
@@ -512,8 +512,8 @@ public void head(String url, AsyncHttpResponseHandler responseHandler) {
512
512
* @param params additional HEAD parameters to send with the request.
513
513
* @param responseHandler the response handler instance that should handle the response.
514
514
*/
515
- public void head (String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
516
- head (null , url , params , responseHandler );
515
+ public RequestHandle head (String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
516
+ return head (null , url , params , responseHandler );
517
517
}
518
518
519
519
/**
@@ -523,8 +523,8 @@ public void head(String url, RequestParams params, AsyncHttpResponseHandler resp
523
523
* @param url the URL to send the request to.
524
524
* @param responseHandler the response handler instance that should handle the response.
525
525
*/
526
- public void head (Context context , String url , AsyncHttpResponseHandler responseHandler ) {
527
- head (context , url , null , responseHandler );
526
+ public RequestHandle head (Context context , String url , AsyncHttpResponseHandler responseHandler ) {
527
+ return head (context , url , null , responseHandler );
528
528
}
529
529
530
530
/**
@@ -535,8 +535,8 @@ public void head(Context context, String url, AsyncHttpResponseHandler responseH
535
535
* @param params additional HEAD parameters to send with the request.
536
536
* @param responseHandler the response handler instance that should handle the response.
537
537
*/
538
- public void head (Context context , String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
539
- sendRequest (httpClient , httpContext , new HttpHead (getUrlWithQueryString (isUrlEncodingEnabled , url , params )), null , responseHandler , context );
538
+ public RequestHandle head (Context context , String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
539
+ return sendRequest (httpClient , httpContext , new HttpHead (getUrlWithQueryString (isUrlEncodingEnabled , url , params )), null , responseHandler , context );
540
540
}
541
541
542
542
/**
@@ -550,10 +550,10 @@ public void head(Context context, String url, RequestParams params, AsyncHttpRes
550
550
* @param responseHandler the response handler instance that should handle
551
551
* the response.
552
552
*/
553
- public void head (Context context , String url , Header [] headers , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
553
+ public RequestHandle head (Context context , String url , Header [] headers , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
554
554
HttpUriRequest request = new HttpHead (getUrlWithQueryString (isUrlEncodingEnabled , url , params ));
555
555
if (headers != null ) request .setHeaders (headers );
556
- sendRequest (httpClient , httpContext , request , null , responseHandler ,
556
+ return sendRequest (httpClient , httpContext , request , null , responseHandler ,
557
557
context );
558
558
}
559
559
@@ -568,8 +568,8 @@ public void head(Context context, String url, Header[] headers, RequestParams pa
568
568
* @param url the URL to send the request to.
569
569
* @param responseHandler the response handler instance that should handle the response.
570
570
*/
571
- public void get (String url , AsyncHttpResponseHandler responseHandler ) {
572
- get (null , url , null , responseHandler );
571
+ public RequestHandle get (String url , AsyncHttpResponseHandler responseHandler ) {
572
+ return get (null , url , null , responseHandler );
573
573
}
574
574
575
575
/**
@@ -579,8 +579,8 @@ public void get(String url, AsyncHttpResponseHandler responseHandler) {
579
579
* @param params additional GET parameters to send with the request.
580
580
* @param responseHandler the response handler instance that should handle the response.
581
581
*/
582
- public void get (String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
583
- get (null , url , params , responseHandler );
582
+ public RequestHandle get (String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
583
+ return get (null , url , params , responseHandler );
584
584
}
585
585
586
586
/**
@@ -590,8 +590,8 @@ public void get(String url, RequestParams params, AsyncHttpResponseHandler respo
590
590
* @param url the URL to send the request to.
591
591
* @param responseHandler the response handler instance that should handle the response.
592
592
*/
593
- public void get (Context context , String url , AsyncHttpResponseHandler responseHandler ) {
594
- get (context , url , null , responseHandler );
593
+ public RequestHandle get (Context context , String url , AsyncHttpResponseHandler responseHandler ) {
594
+ return get (context , url , null , responseHandler );
595
595
}
596
596
597
597
/**
@@ -602,8 +602,8 @@ public void get(Context context, String url, AsyncHttpResponseHandler responseHa
602
602
* @param params additional GET parameters to send with the request.
603
603
* @param responseHandler the response handler instance that should handle the response.
604
604
*/
605
- public void get (Context context , String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
606
- sendRequest (httpClient , httpContext , new HttpGet (getUrlWithQueryString (isUrlEncodingEnabled , url , params )), null , responseHandler , context );
605
+ public RequestHandle get (Context context , String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
606
+ return sendRequest (httpClient , httpContext , new HttpGet (getUrlWithQueryString (isUrlEncodingEnabled , url , params )), null , responseHandler , context );
607
607
}
608
608
609
609
/**
@@ -617,10 +617,10 @@ public void get(Context context, String url, RequestParams params, AsyncHttpResp
617
617
* @param responseHandler the response handler instance that should handle
618
618
* the response.
619
619
*/
620
- public void get (Context context , String url , Header [] headers , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
620
+ public RequestHandle get (Context context , String url , Header [] headers , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
621
621
HttpUriRequest request = new HttpGet (getUrlWithQueryString (isUrlEncodingEnabled , url , params ));
622
622
if (headers != null ) request .setHeaders (headers );
623
- sendRequest (httpClient , httpContext , request , null , responseHandler ,
623
+ return sendRequest (httpClient , httpContext , request , null , responseHandler ,
624
624
context );
625
625
}
626
626
@@ -635,8 +635,8 @@ public void get(Context context, String url, Header[] headers, RequestParams par
635
635
* @param url the URL to send the request to.
636
636
* @param responseHandler the response handler instance that should handle the response.
637
637
*/
638
- public void post (String url , AsyncHttpResponseHandler responseHandler ) {
639
- post (null , url , null , responseHandler );
638
+ public RequestHandle post (String url , AsyncHttpResponseHandler responseHandler ) {
639
+ return post (null , url , null , responseHandler );
640
640
}
641
641
642
642
/**
@@ -646,8 +646,8 @@ public void post(String url, AsyncHttpResponseHandler responseHandler) {
646
646
* @param params additional POST parameters or files to send with the request.
647
647
* @param responseHandler the response handler instance that should handle the response.
648
648
*/
649
- public void post (String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
650
- post (null , url , params , responseHandler );
649
+ public RequestHandle post (String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
650
+ return post (null , url , params , responseHandler );
651
651
}
652
652
653
653
/**
@@ -658,8 +658,8 @@ public void post(String url, RequestParams params, AsyncHttpResponseHandler resp
658
658
* @param params additional POST parameters or files to send with the request.
659
659
* @param responseHandler the response handler instance that should handle the response.
660
660
*/
661
- public void post (Context context , String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
662
- post (context , url , paramsToEntity (params , responseHandler ), null , responseHandler );
661
+ public RequestHandle post (Context context , String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
662
+ return post (context , url , paramsToEntity (params , responseHandler ), null , responseHandler );
663
663
}
664
664
665
665
/**
@@ -671,8 +671,8 @@ public void post(Context context, String url, RequestParams params, AsyncHttpRes
671
671
* @param contentType the content type of the payload you are sending, for example application/json if sending a json payload.
672
672
* @param responseHandler the response ha ndler instance that should handle the response.
673
673
*/
674
- public void post (Context context , String url , HttpEntity entity , String contentType , AsyncHttpResponseHandler responseHandler ) {
675
- sendRequest (httpClient , httpContext , addEntityToRequestBase (new HttpPost (url ), entity ), contentType , responseHandler , context );
674
+ public RequestHandle post (Context context , String url , HttpEntity entity , String contentType , AsyncHttpResponseHandler responseHandler ) {
675
+ return sendRequest (httpClient , httpContext , addEntityToRequestBase (new HttpPost (url ), entity ), contentType , responseHandler , context );
676
676
}
677
677
678
678
/**
@@ -688,12 +688,12 @@ public void post(Context context, String url, HttpEntity entity, String contentT
688
688
* @param responseHandler the response handler instance that should handle
689
689
* the response.
690
690
*/
691
- public void post (Context context , String url , Header [] headers , RequestParams params , String contentType ,
691
+ public RequestHandle post (Context context , String url , Header [] headers , RequestParams params , String contentType ,
692
692
AsyncHttpResponseHandler responseHandler ) {
693
693
HttpEntityEnclosingRequestBase request = new HttpPost (url );
694
694
if (params != null ) request .setEntity (paramsToEntity (params , responseHandler ));
695
695
if (headers != null ) request .setHeaders (headers );
696
- sendRequest (httpClient , httpContext , request , contentType ,
696
+ return sendRequest (httpClient , httpContext , request , contentType ,
697
697
responseHandler , context );
698
698
}
699
699
@@ -712,11 +712,11 @@ public void post(Context context, String url, Header[] headers, RequestParams pa
712
712
* @param responseHandler the response handler instance that should handle
713
713
* the response.
714
714
*/
715
- public void post (Context context , String url , Header [] headers , HttpEntity entity , String contentType ,
715
+ public RequestHandle post (Context context , String url , Header [] headers , HttpEntity entity , String contentType ,
716
716
AsyncHttpResponseHandler responseHandler ) {
717
717
HttpEntityEnclosingRequestBase request = addEntityToRequestBase (new HttpPost (url ), entity );
718
718
if (headers != null ) request .setHeaders (headers );
719
- sendRequest (httpClient , httpContext , request , contentType , responseHandler , context );
719
+ return sendRequest (httpClient , httpContext , request , contentType , responseHandler , context );
720
720
}
721
721
722
722
//
@@ -729,8 +729,8 @@ public void post(Context context, String url, Header[] headers, HttpEntity entit
729
729
* @param url the URL to send the request to.
730
730
* @param responseHandler the response handler instance that should handle the response.
731
731
*/
732
- public void put (String url , AsyncHttpResponseHandler responseHandler ) {
733
- put (null , url , null , responseHandler );
732
+ public RequestHandle put (String url , AsyncHttpResponseHandler responseHandler ) {
733
+ return put (null , url , null , responseHandler );
734
734
}
735
735
736
736
/**
@@ -740,8 +740,8 @@ public void put(String url, AsyncHttpResponseHandler responseHandler) {
740
740
* @param params additional PUT parameters or files to send with the request.
741
741
* @param responseHandler the response handler instance that should handle the response.
742
742
*/
743
- public void put (String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
744
- put (null , url , params , responseHandler );
743
+ public RequestHandle put (String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
744
+ return put (null , url , params , responseHandler );
745
745
}
746
746
747
747
/**
@@ -752,8 +752,8 @@ public void put(String url, RequestParams params, AsyncHttpResponseHandler respo
752
752
* @param params additional PUT parameters or files to send with the request.
753
753
* @param responseHandler the response handler instance that should handle the response.
754
754
*/
755
- public void put (Context context , String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
756
- put (context , url , paramsToEntity (params , responseHandler ), null , responseHandler );
755
+ public RequestHandle put (Context context , String url , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
756
+ return put (context , url , paramsToEntity (params , responseHandler ), null , responseHandler );
757
757
}
758
758
759
759
/**
@@ -766,8 +766,8 @@ public void put(Context context, String url, RequestParams params, AsyncHttpResp
766
766
* @param contentType the content type of the payload you are sending, for example application/json if sending a json payload.
767
767
* @param responseHandler the response handler instance that should handle the response.
768
768
*/
769
- public void put (Context context , String url , HttpEntity entity , String contentType , AsyncHttpResponseHandler responseHandler ) {
770
- sendRequest (httpClient , httpContext , addEntityToRequestBase (new HttpPut (url ), entity ), contentType , responseHandler , context );
769
+ public RequestHandle put (Context context , String url , HttpEntity entity , String contentType , AsyncHttpResponseHandler responseHandler ) {
770
+ return sendRequest (httpClient , httpContext , addEntityToRequestBase (new HttpPut (url ), entity ), contentType , responseHandler , context );
771
771
}
772
772
773
773
/**
@@ -781,10 +781,10 @@ public void put(Context context, String url, HttpEntity entity, String contentTy
781
781
* @param contentType the content type of the payload you are sending, for example application/json if sending a json payload.
782
782
* @param responseHandler the response handler instance that should handle the response.
783
783
*/
784
- public void put (Context context , String url , Header [] headers , HttpEntity entity , String contentType , AsyncHttpResponseHandler responseHandler ) {
784
+ public RequestHandle put (Context context , String url , Header [] headers , HttpEntity entity , String contentType , AsyncHttpResponseHandler responseHandler ) {
785
785
HttpEntityEnclosingRequestBase request = addEntityToRequestBase (new HttpPut (url ), entity );
786
786
if (headers != null ) request .setHeaders (headers );
787
- sendRequest (httpClient , httpContext , request , contentType , responseHandler , context );
787
+ return sendRequest (httpClient , httpContext , request , contentType , responseHandler , context );
788
788
}
789
789
790
790
//
@@ -797,8 +797,8 @@ public void put(Context context, String url, Header[] headers, HttpEntity entity
797
797
* @param url the URL to send the request to.
798
798
* @param responseHandler the response handler instance that should handle the response.
799
799
*/
800
- public void delete (String url , AsyncHttpResponseHandler responseHandler ) {
801
- delete (null , url , responseHandler );
800
+ public RequestHandle delete (String url , AsyncHttpResponseHandler responseHandler ) {
801
+ return delete (null , url , responseHandler );
802
802
}
803
803
804
804
/**
@@ -808,9 +808,9 @@ public void delete(String url, AsyncHttpResponseHandler responseHandler) {
808
808
* @param url the URL to send the request to.
809
809
* @param responseHandler the response handler instance that should handle the response.
810
810
*/
811
- public void delete (Context context , String url , AsyncHttpResponseHandler responseHandler ) {
811
+ public RequestHandle delete (Context context , String url , AsyncHttpResponseHandler responseHandler ) {
812
812
final HttpDelete delete = new HttpDelete (url );
813
- sendRequest (httpClient , httpContext , delete , null , responseHandler , context );
813
+ return sendRequest (httpClient , httpContext , delete , null , responseHandler , context );
814
814
}
815
815
816
816
/**
@@ -821,10 +821,10 @@ public void delete(Context context, String url, AsyncHttpResponseHandler respons
821
821
* @param headers set one-time headers for this request
822
822
* @param responseHandler the response handler instance that should handle the response.
823
823
*/
824
- public void delete (Context context , String url , Header [] headers , AsyncHttpResponseHandler responseHandler ) {
824
+ public RequestHandle delete (Context context , String url , Header [] headers , AsyncHttpResponseHandler responseHandler ) {
825
825
final HttpDelete delete = new HttpDelete (url );
826
826
if (headers != null ) delete .setHeaders (headers );
827
- sendRequest (httpClient , httpContext , delete , null , responseHandler , context );
827
+ return sendRequest (httpClient , httpContext , delete , null , responseHandler , context );
828
828
}
829
829
830
830
/**
@@ -836,10 +836,10 @@ public void delete(Context context, String url, Header[] headers, AsyncHttpRespo
836
836
* @param params additional DELETE parameters or files to send along with request
837
837
* @param responseHandler the response handler instance that should handle the response.
838
838
*/
839
- public void delete (Context context , String url , Header [] headers , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
839
+ public RequestHandle delete (Context context , String url , Header [] headers , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
840
840
HttpDelete httpDelete = new HttpDelete (getUrlWithQueryString (isUrlEncodingEnabled , url , params ));
841
841
if (headers != null ) httpDelete .setHeaders (headers );
842
- sendRequest (httpClient , httpContext , httpDelete , null , responseHandler , context );
842
+ return sendRequest (httpClient , httpContext , httpDelete , null , responseHandler , context );
843
843
}
844
844
845
845
/**
@@ -852,7 +852,7 @@ public void delete(Context context, String url, Header[] headers, RequestParams
852
852
* @param responseHandler ResponseHandler or its subclass to put the response into
853
853
* @param uriRequest instance of HttpUriRequest, which means it must be of HttpDelete, HttpPost, HttpGet, HttpPut, etc.
854
854
*/
855
- protected void sendRequest (DefaultHttpClient client , HttpContext httpContext , HttpUriRequest uriRequest , String contentType , AsyncHttpResponseHandler responseHandler , Context context ) {
855
+ protected RequestHandle sendRequest (DefaultHttpClient client , HttpContext httpContext , HttpUriRequest uriRequest , String contentType , AsyncHttpResponseHandler responseHandler , Context context ) {
856
856
if (contentType != null ) {
857
857
uriRequest .addHeader ("Content-Type" , contentType );
858
858
}
@@ -871,6 +871,8 @@ protected void sendRequest(DefaultHttpClient client, HttpContext httpContext, Ht
871
871
872
872
// TODO: Remove dead weakrefs from requestLists?
873
873
}
874
+
875
+ return new RequestHandle (request );
874
876
}
875
877
876
878
/**
0 commit comments