hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kalnichevski, Oleg" <oleg.kalnichev...@bearingpoint.com>
Subject RE: SSL & proxy question
Date Fri, 24 Jan 2003 17:09:31 GMT
Armando
Would you permit me to tweak your example a bit and add it to Httpclient's collection of examples?
Cheers
Oleg

-----Original Message-----
From: Armando Anton [mailto:armando.anton@newknow.com]
Sent: Freitag, 24. Januar 2003 17:58
To: Commons HttpClient Project
Subject: RE: SSL & proxy question


Thank you for helping :)

i finally can connect to a secure web using the proxy and the HttpConnection class instead
of the HttpClient :)

i will post here my example code (perhaps it helps to someome more)

import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.GetMethod;

public class TestSSLAndProxy {

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

        HttpState state = new HttpState();
        String _uri = "https://www.pairnic.com:443/main.m";
         URI uri = new URI(_uri.toCharArray()); // i like this constructor :)
        boolean isSecure = uri.getScheme() != null &&
                uri.getScheme().equals("https");
        HttpMethod method = new GetMethod( uri.toString() );
        ConnectMethod connectMethod = null;
        String host = uri.getHost();
        int port = uri.getPort();
        HttpConnection connection = new HttpConnection( host, port, isSecure );
        connection.setProxyHost("proxy.xxx.com");
        connection.setProxyPort(80);
        int status = 0;
        if (connection.isProxied() && connection.isSecure()) {
            connectMethod = new ConnectMethod(method);
            status = connectMethod.execute(state, connection);
        } else {
            status = method.execute(state, connection);
        }

        System.out.println("Status: " + status);
        System.out.println(method.getResponseBodyAsString());
    }
}

Armando

-----Original Message-----
From: Armando Anton 
Sent: viernes, 24 de enero de 2003 17:19
To: Commons HttpClient Project
Subject: RE: SSL & proxy question


Hi SSL friends :)

I know that the proxy accepts a CONNECT method when requesting secure pages.

But i uses directly an HttpConnection configured with a proxy when accesing to non-secure
pages and it works perfect, but when accesing to secure pages i have the problem i have reported

Now i have the doubt if i must change how i use and manage the HttpConnection when accesing
to secure pages or the HttpConnection (or HttpMethodBase) should be smarter and do it transparently.

Thanks,

Armando



-----Original Message-----
From: Ortwin Gl├╝ck [mailto:ortwin.glueck@nose.ch]
Sent: viernes, 24 de enero de 2003 17:06
To: Commons HttpClient Project
Subject: Re: SSL & proxy question


You were basically trying to send a GET directly to the Proxy. But the 
proxy accepts a CONNECT method only.


--
To unsubscribe, e-mail:   <mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-httpclient-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-httpclient-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:commons-httpclient-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-httpclient-dev-help@jakarta.apache.org>


Mime
View raw message