Hi everybody,
Does any one can provide me an sample to show me how to use
HttpConnection.tunnelCreated()
I would like to tunnel my proxy and establish a connection so that I can
read iformation and send response over the same connexion.
I try this, but it is not work
HostConfiguration hostConf = new HostConfiguration() ;
try {
hostConf.setHost(new URI("https://myserver",false));
hostConf.setProxy("myproxy", 8080) ;
List authPrefs = new ArrayList(3);
authPrefs.add(AuthPolicy.DIGEST);
authPrefs.add(AuthPolicy.BASIC);
authPrefs.add(AuthPolicy.NTLM);
// This will exclude the NTLM authentication scheme
httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY,
authPrefs);
httpClient.getParams().setVersion(HttpVersion.HTTP_1_1) ;
httpClient.getParams().setAuthenticationPreemptive(true) ;
Credentials userCredential = new
UsernamePasswordCredentials("mylogin", "mypassword") ;
httpClient.getState().setProxyCredentials(new
AuthScope("proxyftm", 8080,AuthScope.ANY_REALM), userCredential) ;
httpClient.setHostConfiguration(hostConf) ;
HttpConnection conn =
httpClient.getHttpConnectionManager().getConnection(hostConf) ;
conn.open() ;
conn.tunnelCreated() ;
GetMethod method = new GetMethod() ;
int code = method.execute(httpClient.getState(), conn) ;
if(code == 200 ) {
BufferedReader din = new BufferedReader(new
InputStreamReader(conn.getLastResponseInputStream()));
String text = din.readLine() ;
int i = 0 ;
while(text != null){
System.out.println(text);
text = din.readLine() ;
}
System.out.println("fin.");
}
} catch(Throwable e) {
e.printStackTrace() ;
}
I get this error:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at com.sun.net.ssl.internal.ssl.InputRecord.b(DashoA12275)
at com.sun.net.ssl.internal.ssl.InputRecord.read(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA12275)
at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:66)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:124)
at
org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:827)
at
org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1975)
at
org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
at test.KeepCLient.connectWithHttpConnection(KeepCLient.java:125)
at test.KeepCLient.main(KeepCLient.java:52)
Thanks a lot.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]