Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Optional passing of SSLSocketFactory #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion default.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
target=android-3
target=android-1.6
2 changes: 1 addition & 1 deletion local.properties.dist
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sdk.dir=/usr/local/android_sdk/
sdk.dir=/android-sdk-mac/
21 changes: 14 additions & 7 deletions src/com/loopj/android/http/AsyncHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.lang.ref.WeakReference;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.lang.ref.WeakReference;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
Expand All @@ -39,13 +39,12 @@
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.HttpVersion;
import org.apache.http.client.CookieStore;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.conn.params.ConnPerRouteBean;
Expand All @@ -60,8 +59,8 @@
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.SyncBasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.SyncBasicHttpContext;

import android.content.Context;

Expand Down Expand Up @@ -106,6 +105,10 @@ public class AsyncHttpClient {
* @param userAgent the identifier to use in the User-Agent header in requests
*/
public AsyncHttpClient(String userAgent) {
new AsyncHttpClient(userAgent, null);
}

public AsyncHttpClient(String userAgent, SSLSocketFactory sslSocketFactory) {
BasicHttpParams httpParams = new BasicHttpParams();

ConnManagerParams.setTimeout(httpParams, socketTimeout);
Expand All @@ -120,7 +123,11 @@ public AsyncHttpClient(String userAgent) {

SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));

if (sslSocketFactory == null) {
sslSocketFactory = SSLSocketFactory.getSocketFactory();
}
schemeRegistry.register(new Scheme("https", sslSocketFactory, 443));
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(httpParams, schemeRegistry);

httpContext = new SyncBasicHttpContext(new BasicHttpContext());
Expand Down