Skip to content
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

Initialization fix #71

Merged
merged 3 commits into from
Mar 22, 2012
Merged
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
16 changes: 16 additions & 0 deletions org.ektorp/src/main/java/org/ektorp/http/StdHttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,21 @@ public Builder url(String s) throws MalformedURLException {
public Builder url(URL url){
this.host = url.getHost();
this.port = url.getPort();
if (url.getUserInfo() != null) {
String[] userInfoParts = url.getUserInfo().split(":");
if (userInfoParts.length == 2) {
this.username = userInfoParts[0];
this.password = userInfoParts[1];
}
}
enableSSL("https".equals(url.getProtocol()));
if (this.port == -1) {
if (this.enableSSL) {
this.port = 443;
} else {
this.port = 80;
}
}
return this;
}

Expand Down Expand Up @@ -270,6 +284,8 @@ public void checkServerTrusted(
String authType) {
}
} }, null);
} else {
context.init(null, null, null);
}

sslSocketFactory = relaxedSSLSettings ? new SSLSocketFactory(context, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER) : new SSLSocketFactory(context);
Expand Down