Does it matter that I just use a HttpClient and not a Proxy Client?... I
use HostConfiguration.setProxy when I need a proxy..
also
import org.apache.commons.httpclient.auth.AuthScope;
doesn't exist... in 2.0.2 should I upgrade?
Med vänliga hälsningar/Best regards
Benjamin Janes
------------------------------------------
System Development
IBM Sverige AB
V. Varvsgatan 19, 211 19 Malmö
Cell Phone no.: +46 (0)707 93 62 89
e-mail: [EMAIL PROTECTED]
"Ramit Bhardwaj"
<[EMAIL PROTECTED]
m> To
"HttpClient User Discussion"
2005-11-21 10:06 <[email protected]
>
cc
Please respond to
"HttpClient User Subject
Discussion" RE: Proxy Authentication
if u have it working for proxies without authentication, the perhaps realm
wont matter..so pass null...as i have done ...just see if it can help u..
try the following code:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.Socket;
import org.apache.commons.httpclient.ProxyClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
public class ProxyTestForHTTPClient {
public static void main(String[] args) throws Exception {
ProxyClient proxyclient = new ProxyClient();
proxyclient.getHostConfiguration().setHost("
http://www.mysite.com/index.html");
// set the proxy host and port
proxyclient.getHostConfiguration().setProxy("proxy.acompany.com",
8080);
// set the proxy credentials, only necessary for authenticating
proxies
proxyclient.getState().setProxyCredentials(
new AuthScope("proxy.acompany.com", 8080, null),new
UsernamePasswordCredentials("proxyUser", "proxyPwd"));
// create the socket
ProxyClient.ConnectResponse response = proxyclient.connect();
//Now do whatever u want
}
}
Best Regards
-----Original Message-----
From: Benjamin Janes [mailto:[EMAIL PROTECTED]
Sent: Monday, November 21, 2005 1:16 PM
To: [email protected]
Subject: Proxy Authentication
Hi,
I have a site i want to reach
www.mysite.com/index.html
a proxy
proxy.acompany.com
and port
8080
and proxy username and pwd
proxyUser & proxyPwd
how do I set the proxy username / pwd, namlely what is the realm? and and
what do I enter in [[WHAT GOES HERE]],
myState = new HttpState();
myState.setCookiePolicy(CookiePolicy.RFC2109);
.......
UsernamePasswordCredentials upc = new
UsernamePasswordCredentials(proxyUser ,proxyPwd);
myState.setProxyCredentials([[WHAT GOES
HERE]],"proxy.acompany.com",upc);
.......
myClient.setState(myState);
I have it working for prxies without authentication....
Med vänliga hälsningar/Best regards
Benjamin Janes
------------------------------------------
System Development
IBM Sverige AB
V. Varvsgatan 19, 211 19 Malmö
Cell Phone no.: +46 (0)707 93 62 89
e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]