19
19
package com .loopj .android .http ;
20
20
21
21
import android .content .Context ;
22
+ import android .util .Log ;
22
23
23
24
import org .apache .http .Header ;
24
25
import org .apache .http .HeaderElement ;
@@ -104,6 +105,7 @@ public class AsyncHttpClient {
104
105
private static final int DEFAULT_SOCKET_BUFFER_SIZE = 8192 ;
105
106
private static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding" ;
106
107
private static final String ENCODING_GZIP = "gzip" ;
108
+ private static final String LOG_TAG = "AsyncHttpClient" ;
107
109
108
110
private static int maxConnections = DEFAULT_MAX_CONNECTIONS ;
109
111
private static int socketTimeout = DEFAULT_SOCKET_TIMEOUT ;
@@ -128,6 +130,8 @@ public AsyncHttpClient() {
128
130
* @param fixNoHttpResponseException See issue https://github.com/loopj/android-async-http/issues/143
129
131
*/
130
132
public AsyncHttpClient (boolean fixNoHttpResponseException ) {
133
+ if (fixNoHttpResponseException )
134
+ Log .d (LOG_TAG , "Beware! Using the fix is insecure, as it doesn't verify SSL certificates." );
131
135
BasicHttpParams httpParams = new BasicHttpParams ();
132
136
133
137
ConnManagerParams .setTimeout (httpParams , socketTimeout );
@@ -145,7 +149,7 @@ public AsyncHttpClient(boolean fixNoHttpResponseException) {
145
149
// Fix to SSL flaw in API < ICS
146
150
// See https://code.google.com/p/android/issues/detail?id=13117
147
151
SSLSocketFactory sslSocketFactory ;
148
- if (fixNoHttpResponseException )
152
+ if (fixNoHttpResponseException )
149
153
sslSocketFactory = MySSLSocketFactory .getFixedSocketFactory ();
150
154
else
151
155
sslSocketFactory = SSLSocketFactory .getSocketFactory ();
@@ -277,10 +281,10 @@ public void setTimeout(int timeout) {
277
281
/**
278
282
* Sets the Proxy by it's hostname and port
279
283
*
280
- * @param hostname the hostname (IP or DNS name)
281
- * @param port the port number. -1 indicates the scheme default port.
284
+ * @param hostname the hostname (IP or DNS name)
285
+ * @param port the port number. -1 indicates the scheme default port.
282
286
*/
283
- public void setProxy (String hostname , int port ){
287
+ public void setProxy (String hostname , int port ) {
284
288
final HttpHost proxy = new HttpHost (hostname , port );
285
289
final HttpParams httpParams = this .httpClient .getParams ();
286
290
httpParams .setParameter (ConnRoutePNames .DEFAULT_PROXY , proxy );
@@ -298,6 +302,7 @@ public void setSSLSocketFactory(SSLSocketFactory sslSocketFactory) {
298
302
299
303
/**
300
304
* Sets the maximum number of retries for a particular Request.
305
+ *
301
306
* @param retries maximum number of retries per request
302
307
*/
303
308
public void setMaxRetries (int retries ) {
@@ -350,8 +355,8 @@ public void setBasicAuth(String username, String password, AuthScope scope) {
350
355
351
356
/**
352
357
* Removes set basic auth credentials
353
- * * /
354
- public void clearBasicAuth (){
358
+ */
359
+ public void clearBasicAuth () {
355
360
this .httpClient .getCredentialsProvider ().clear ();
356
361
}
357
362
@@ -727,7 +732,7 @@ public void delete(Context context, String url, Header[] headers, AsyncHttpRespo
727
732
*/
728
733
public void delete (Context context , String url , Header [] headers , RequestParams params , AsyncHttpResponseHandler responseHandler ) {
729
734
HttpDelete httpDelete = new HttpDelete (getUrlWithQueryString (url , params ));
730
- if (headers != null ) httpDelete .setHeaders (headers );
735
+ if (headers != null ) httpDelete .setHeaders (headers );
731
736
sendRequest (httpClient , httpContext , httpDelete , null , responseHandler , context );
732
737
}
733
738
0 commit comments