@ Override public Response performRequest ( Request < ? > request , Map < String , String > additionalHeaders ) throws IOException , AuthFailureError { String url = request . getUrl ( ) ; HashMap < String , String > map = new HashMap < String , String > ( ) ; map . putAll ( request . getHeaders ( ) ) ; map . putAll ( additionalHeaders ) ; if ( mUrlRewriter != null ) { String rewritten = mUrlRewriter . rewriteUrl ( url ) ; if ( rewritten == null ) { throw new IOException ( "URL blocked by rewriter: " + url ) ; } url = rewritten ; } com . squareup . okhttp . Request . Builder builder = new com . squareup . okhttp . Request . Builder ( ) ; builder . url ( url ) ; for ( String headerName : map . keySet ( ) ) { builder . header ( headerName , map . get ( headerName ) ) ; // connection.addRequestProperty(headerName, map.get(headerName)); if ( VolleyLog . DEBUG ) { // print header message VolleyLog . d ( "RequestHeader: %1$s:%2$s" , headerName , map . get ( headerName ) ) ; } } setConnectionParametersForRequest ( builder , request ) ; // Initialize HttpResponse with data from the okhttp. Response okHttpResponse = mClient . newCall ( builder . build ( ) ) . execute ( ) ; int responseCode = okHttpResponse . code ( ) ; if ( responseCode == - 1 ) { // -1 is returned by getResponseCode() if the response code could not be retrieved. // Signal to the caller that something was wrong with the connection. throw new IOException ( "Could not retrieve response code from HttpUrlConnection." ) ; } return okHttpResponse ; }
perform the request