Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed proxy issue. JENKINS-22657
  • Loading branch information
Lukasz Milewski committed Apr 28, 2014
1 parent 350eaf2 commit 5ce1237
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/main/java/hockeyapp/HockeyappRecorder.java
Expand Up @@ -7,15 +7,21 @@
import hudson.Util;
import hudson.model.*;
import hudson.model.AbstractBuild;
import hudson.ProxyConfiguration;
import hudson.tasks.*;
import hudson.util.RunList;
import org.apache.commons.collections.Predicate;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
Expand Down Expand Up @@ -110,9 +116,25 @@ public boolean isDebugEnabled() {
// note that this doesn't solve potential write timeouts
// http://stackoverflow.com/questions/1338885/java-socket-output-stream-writes-do-they-block
private HttpClient createPreconfiguredHttpClient() {
HttpClient httpclient = new DefaultHttpClient();
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000);
httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 60000);

// Proxy setting
if (Hudson.getInstance() != null && Hudson.getInstance().proxy != null) {

ProxyConfiguration configuration = Hudson.getInstance().proxy;
Credentials cred = null;

if (configuration.getUserName() != null && !configuration.getUserName().isEmpty()) {
cred = new UsernamePasswordCredentials(configuration.getUserName(), configuration.getPassword());
}

httpclient.getCredentialsProvider().setCredentials(new AuthScope(configuration.name, configuration.port), cred);
HttpHost proxy = new HttpHost(configuration.name, configuration.port);
httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
}

return httpclient;
}

Expand Down

0 comments on commit 5ce1237

Please sign in to comment.