hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "pavan kumar" <pavanku...@dellmail.com>
Subject HTTP/1.1 502 Proxy Error
Date Mon, 13 Jun 2005 04:23:58 GMT
Hi All,

The ProxyTunnelDemo.java program in Apache sample throws me the below error. Can some one
point out what am I missing to do the Tunnelling. Will there be a problem if my proxy allows
NTLM authentication.

[INFO] HttpMethodDirector - -I/O exception caught when processing request: Connection aborted
by peer: no further information
[INFO] HttpMethodDirector - -Retrying request
[INFO] HttpMethodBase - -Response content length is not known
TEST org.apache.commons.httpclient.ProxyClient$ConnectResponse@5d56d5
Connect failed: HTTP/1.1 502 Proxy Error ( SSL port specified is not allowed.  )
[WARN] HttpMethodBase - -Going to buffer response body of large or unknown size. Using getResponseAs
Stream instead is recommended.
Exception in thread "main" java.io.IOException: Stream closed
        at java.io.BufferedInputStream.ensureOpen(BufferedInputStream.java:123)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:273)
        at java.io.FilterInputStream.read(FilterInputStream.java:114)
        at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:107)
        at java.io.FilterInputStream.read(FilterInputStream.java:93)
        at org.apache.commons.httpclient.AutoCloseInputStream.read(AutoCloseInputStream.java:126)
        at org.apache.commons.httpclient.HttpMethodBase.getResponseBody(HttpMethodBase.java:684)
        at org.apache.commons.httpclient.HttpMethodBase.getResponseBodyAsString(HttpMethodBase.java:
        at ProxyTunnelDemo.main(ProxyTunnelDemo.java:63)

=== Program ====
public class ProxyTunnelDemo {

    public static void main(String[] args) throws Exception {

        ProxyClient proxyclient = new ProxyClient();
        // set the host the proxy should create a connection to
        // Note:  By default port 443 will be used. Some proxies only allow conections
        // to ports 443 and 8443.  This is because the HTTP CONNECT method was intented
        // to be used for tunneling HTTPS.
        // set the proxy host and port
        proxyclient.getHostConfiguration().setProxy("PROXY", 443);

            new AuthScope("PROXY",AuthScope.ANY_PORT,AuthScope.ANY_REALM,"NTLM"),
new NTCredentials("inter", "test123", "PROXY", "NONE"));

ProxyClient.ConnectResponse response = proxyclient.connect();
Socket s=new Socket("PROXY",443);
System.out.println("TEST " + response);
        if (response.getSocket() != null) {
            Socket socket = response.getSocket();
            try {
                Writer out = new OutputStreamWriter(
                    socket.getOutputStream(), "ISO-8859-1");
                out.write("GET http://www.yahoo.com/ HTTP/1.0\r\n");
                out.write("Host: www.yahoo.com\r\n");
                out.write("Agent: whatever\r\n");
                BufferedReader in = new BufferedReader(
                    new InputStreamReader(socket.getInputStream(), "ISO-8859-1"));
                String line = null;
                while ((line = in.readLine()) != null) {
            } finally {
        } else {
            System.out.println("Connect failed: " + response.getConnectMethod().getStatusLine());
 }    }}

Thanks in advance
Pavan kumar

Get your free email from http://www.dellmail.com

To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org

View raw message