hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "nitya vyas" <nitya.v...@gmail.com>
Subject Re: http/ https connection issue for HTTPClient 3.1
Date Tue, 30 Oct 2007 05:59:43 GMT
Sorry.. half message... below is the completed code... this now works for
http requests with/without proxy...

thanks.

On 10/30/07, nitya vyas <nitya.vyas@gmail.com> wrote:
>
> Hi Julius,
>
> I think this Protocol.registerProtocol("https", stricthttps); will not
> work with httpClient 3.1 if i m not mistaken.. because open() method of
> HTTPConnection has this code...
>
> if (isSecure() && isProxied()) {
>         Protocol defaultprotocol = Protocol.getProtocol("http");
>          socketFactory = defaultprotocol.getSocketFactory();
>  } else {
>        socketFactory = this.protocolInUse.getSocketFactory();
>  }
> Thers no code that gets the socketfactory from ID "https"...
>
> Anyways i found another solution for the problem .. i dont know if its
> proper... I removed the extends StrictSSL
>
>
> public class AsiteSocketFactory implements ProtocolSocketFactory {
>
>     public AsiteSocketFactory(boolean isHttps) throws
> java.security.GeneralSecurityException, java.io.IOException{
>
>           if(isHttps){
>
                 new StrictSSLProtocolSocketFactory(true);
          }else{

>               new DefaultProtocolSocketFactory();
>     }
>
>     public Socket createSocket(String host, int port) throws IOException,
> UnknownHostException {
>        return new Socket(host,port);
>     }
>
>     public Socket createSocket(String host, int port, InetAddress
> localAddress, int localPort) throws IOException, UnknownHostException {
>         return new Socket(host,port,localAddress,localPort);
>     }
>
>     public Socket createSocket(String host, int port, InetAddress
> localAddress, int localPort, HttpConnectionParams params)
>             throws IOException, UnknownHostException, ConnectException {
>         Socket rval;
>         if (params == null) {
>             throw new IllegalArgumentException("Parameters may not be
> null");
>         }
>         rval = new Socket(Proxy.NO_PROXY);
>         SocketAddress localaddr = new
>         InetSocketAddress(localAddress, localPort);
>         SocketAddress remoteaddr = new InetSocketAddress(host, port);
>         rval.bind(localaddr);
>         rval.connect(remoteaddr);
>         return rval;
>     }
> }
>
>
> On 10/29/07, Julius Davies <juliusdavies@gmail.com> wrote:
> >
> > I would recommend replacing this:
> > Protocol.registerProtocol("http", stricthttps);
> >
> >
> > With this:
> > Protocol.registerProtocol("https", stricthttps);
> >
> >
> > --
> > yours,
> >
> > Julius Davies
> > 250-592-2284 (Home)
> > 250-893-4579 (Mobile)
> > http://juliusdavies.ca/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message