private HttpURLConnection makeConnection(URL url,byte[] postBody,long position,long length,boolean allowGzip,boolean followRedirects) throws IOException {
  HttpURLConnection connection=(HttpURLConnection)url.openConnection();
  connection.setConnectTimeout(connectTimeoutMillis);
  connection.setReadTimeout(readTimeoutMillis);
synchronized (requestProperties) {
    for (    Map.Entry<String,String> property : requestProperties.entrySet()) {
      connection.setRequestProperty(property.getKey(),property.getValue());
    }
  }
  if (!(position == 0 && length == C.LENGTH_UNBOUNDED)) {
    String rangeRequest="bytes=" + position + "-";
    if (length != C.LENGTH_UNBOUNDED) {
      rangeRequest+=(position + length - 1);
    }
    connection.setRequestProperty("Range",rangeRequest);
  }
  connection.setRequestProperty("User-Agent",userAgent);
  if (!allowGzip) {
    connection.setRequestProperty("Accept-Encoding","identity");
  }
  connection.setInstanceFollowRedirects(followRedirects);
  connection.setDoOutput(postBody != null);
  if (postBody != null) {
    connection.setFixedLengthStreamingMode(postBody.length);
    connection.connect();
    OutputStream os=connection.getOutputStream();
    os.write(postBody);
    os.close();
  }
 else {
    connection.connect();
  }
  return connection;
}

private HttpURLConnection makeConnection ( URL url , byte [ ] postBody , long position , long length , boolean allowGzip , boolean followRedirects ) throws IOException { HttpURLConnection connection = ( HttpURLConnection ) url . openConnection ( ) ; connection . setConnectTimeout ( connectTimeoutMillis ) ; connection . setReadTimeout ( readTimeoutMillis ) ; synchronized ( requestProperties ) { for ( Map . Entry < String , String > property : requestProperties . entrySet ( ) ) { connection . setRequestProperty ( property . getKey ( ) , property . getValue ( ) ) ; } } if ( ! ( position == 0 && length == C . LENGTH_UNBOUNDED ) ) { String rangeRequest = "bytes=" + position + "-" ; if ( length != C . LENGTH_UNBOUNDED ) { rangeRequest += ( position + length - 1 ) ; } connection . setRequestProperty ( "Range" , rangeRequest ) ; } connection . setRequestProperty ( "User-Agent" , userAgent ) ; if ( ! allowGzip ) { connection . setRequestProperty ( "Accept-Encoding" , "identity" ) ; } connection . setInstanceFollowRedirects ( followRedirects ) ; connection . setDoOutput ( postBody != null ) ; if ( postBody != null ) { connection . setFixedLengthStreamingMode ( postBody . length ) ; connection . connect ( ) ; OutputStream os = connection . getOutputStream ( ) ; os . write ( postBody ) ; os . close ( ) ; } else { connection . connect ( ) ; } return connection ; }
configures a connection and opens it .
