public HttpURLConnection createConnection ( TLSClientParameters tlsClientParameters , Proxy proxy , URL url ) throws IOException { HttpURLConnection connection = ( HttpURLConnection ) ( proxy != null ? url . openConnection ( proxy ) : url . openConnection ( ) ) ; if ( HTTPS_URL_PROTOCOL_ID . equals ( url . getProtocol ( ) ) ) { if ( tlsClientParameters == null ) { tlsClientParameters = new TLSClientParameters ( ) ; } Exception ex = null ; try { decorateWithTLS ( tlsClientParameters , connection ) ; } catch ( Exception e ) { ex = e ; } finally { if ( ex != null ) { if ( ex instanceof IOException ) { throw ( IOException ) ex ; } // use exception.initCause(ex) to be java 5 compatible IOException ioException = new IOException ( "Error while initializing secure socket" ) ; ioException . initCause ( ex ) ; throw ioException ; } } } return connection ; }
Create a HttpURLConnection proxified if necessary .