Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Http Client Proxy

Hi All 

Iam using jetty client/http 7.4.4 jars & my http/https request times out when my setting the proxy . I tried with the jetty 9.0.4 client jars even then its the same. The time out happens. 

Can you please advise over this. ?

The sample code i wrote looks like this while using 9.0.4 jars
/****
               HttpClient client = new HttpClient(new SslContextFactory(true));
String url = "" href="https://login.salesforce.com">https://login.salesforce.com";
URI uri = new URI(url);
String realm = "TestRealm";
String user = "userName";
String pass = "password";
ProxyConfiguration proxy = new ProxyConfiguration("proxyServer", 443);
client.setProxyConfiguration(proxy);
AuthenticationStore store = client.getAuthenticationStore();
store.addAuthentication(new BasicAuthentication(uri, realm, user, pass));
client.start();
Request req = client.POST(url);
//System.out.println(req.getContent().toString());
ContentResponse response = client.POST(url).send();

***/

The sample code i wrote looks like this while using 7.4.4 jars

/***


Address proxy = new Address(proxyHost,Integer.parseInt(proxyPort));
httpClient.setProxy(proxy);
Authentication auth = null;
try {
auth = new ProxyAuthorization(proxyUser, proxyPassword);
} catch (IOException e) {
// TODO Auto-generated catch block
//e.printStackTrace();
}
if(auth!=null){
httpClient.setProxyAuthentication(auth);
}


         httpClient.send(exchange);


Back to the top