private URLConnection openConnection ( ) throws IOException { final URLConnection connection = url . openConnection ( ) ; connection . setUseCaches ( false ) ; if ( CONNECTION_TIMEOUT > 0 ) { connection . setConnectTimeout ( CONNECTION_TIMEOUT ) ; } if ( READ_TIMEOUT > 0 ) { connection . setReadTimeout ( READ_TIMEOUT ) ; } // grâce à cette propriété, l'application retournera un flux compressé si la taille // dépasse x Ko connection . setRequestProperty ( "Accept-Encoding" , "gzip" ) ; if ( headers != null ) { for ( final Map . Entry < String , String > entry : headers . entrySet ( ) ) { connection . setRequestProperty ( entry . getKey ( ) , entry . getValue ( ) ) ; } } if ( url . getUserInfo ( ) != null ) { final String authorization = Base64Coder . encodeString ( url . getUserInfo ( ) ) ; connection . setRequestProperty ( "Authorization" , "Basic " + authorization ) ; } return connection ; }
Ouvre la connection http .