|
40 | 40 | import org.apache.http.client.CredentialsProvider;
|
41 | 41 | import org.apache.http.client.HttpClient;
|
42 | 42 | import org.apache.http.client.RedirectHandler;
|
43 |
| -import org.apache.http.client.methods.HttpDelete; |
44 | 43 | import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
|
45 |
| -import org.apache.http.client.methods.HttpGet; |
46 | 44 | import org.apache.http.client.methods.HttpHead;
|
47 | 45 | import org.apache.http.client.methods.HttpPost;
|
48 | 46 | import org.apache.http.client.methods.HttpPut;
|
|
69 | 67 | import org.apache.http.protocol.ExecutionContext;
|
70 | 68 | import org.apache.http.protocol.HttpContext;
|
71 | 69 | import org.apache.http.protocol.SyncBasicHttpContext;
|
| 70 | +import org.json.JSONObject; |
72 | 71 |
|
73 | 72 | import java.io.IOException;
|
74 | 73 | import java.io.InputStream;
|
@@ -901,6 +900,23 @@ public RequestHandle get(Context context, String url, Header[] headers, RequestP
|
901 | 900 | context);
|
902 | 901 | }
|
903 | 902 |
|
| 903 | + /** |
| 904 | + * Perform a HTTP GET request and track the Android Context which initiated the request. |
| 905 | + * |
| 906 | + * @param context the Android Context which initiated the request. |
| 907 | + * @param url the URL to send the request to. |
| 908 | + * @param entity a raw {@link org.apache.http.HttpEntity} to send with the request, for |
| 909 | + * example, use this to send string/json/xml payloads to a server by |
| 910 | + * passing a {@link org.apache.http.entity.StringEntity}. |
| 911 | + * @param contentType the content type of the payload you are sending, for example |
| 912 | + * application/json if sending a json payload. |
| 913 | + * @param responseHandler the response ha ndler instance that should handle the response. |
| 914 | + * @return RequestHandle of future request process |
| 915 | + */ |
| 916 | + public RequestHandle get(Context context, String url, HttpEntity entity, String contentType, ResponseHandlerInterface responseHandler) { |
| 917 | + return sendRequest(httpClient, httpContext, addEntityToRequestBase(new HttpGet(URI.create(url).normalize()), entity), contentType, responseHandler, context); |
| 918 | + } |
| 919 | + |
904 | 920 | // [-] HTTP GET
|
905 | 921 | // [+] HTTP POST
|
906 | 922 |
|
@@ -1206,6 +1222,23 @@ public RequestHandle delete(Context context, String url, Header[] headers, Reque
|
1206 | 1222 | return sendRequest(httpClient, httpContext, httpDelete, null, responseHandler, context);
|
1207 | 1223 | }
|
1208 | 1224 |
|
| 1225 | + /** |
| 1226 | + * Perform a HTTP DELETE request and track the Android Context which initiated the request. |
| 1227 | + * |
| 1228 | + * @param context the Android Context which initiated the request. |
| 1229 | + * @param url the URL to send the request to. |
| 1230 | + * @param entity a raw {@link org.apache.http.HttpEntity} to send with the request, for |
| 1231 | + * example, use this to send string/json/xml payloads to a server by |
| 1232 | + * passing a {@link org.apache.http.entity.StringEntity}. |
| 1233 | + * @param contentType the content type of the payload you are sending, for example |
| 1234 | + * application/json if sending a json payload. |
| 1235 | + * @param responseHandler the response ha ndler instance that should handle the response. |
| 1236 | + * @return RequestHandle of future request process |
| 1237 | + */ |
| 1238 | + public RequestHandle delete(Context context, String url, HttpEntity entity, String contentType, ResponseHandlerInterface responseHandler) { |
| 1239 | + return sendRequest(httpClient, httpContext, addEntityToRequestBase(new HttpDelete(URI.create(url).normalize()), entity), contentType, responseHandler, context); |
| 1240 | + } |
| 1241 | + |
1209 | 1242 | // [-] HTTP DELETE
|
1210 | 1243 |
|
1211 | 1244 | /**
|
|
0 commit comments