Performs a request
@param url the URL to query
@param additionalHeaders additional HTTP request headers (may be null)
@return the response
@throws IOException if the request was not successful
4440
protected Response performRequest(String url,
			Map<String, String> additionalHeaders) throws IOException {
		if (accessToken == null) {
			throw new UnauthorizedException("Access token has not yet been requested");
		}
		URL u = new URL(url);
		return auth.request(u, Method.GET, accessToken, additionalHeaders);
	}
730911
public static HTTPResponse get(URL url, String username, String password, long timeout, boolean redirect, String charset, String useragent, ProxyData proxy,
	    lucee.commons.net.http.Header[] headers) throws IOException {
	HttpGet get = new HttpGet(url.toExternalForm());
	return _invoke(url, get, username, password, timeout, redirect, charset, useragent, proxy, headers, null);
    }
572275
protected HttpResponse execute(final HttpMethod meth, String postURL) throws IOException {
		final String url = (meth == HttpMethod.POST) ? postURL : this.toString();

		if (log.isLoggable(Level.FINER))
			log.finer(meth + "ing: " + url);

		return RequestExecutor.instance().execute(this.retries, new RequestSetup() {
			public void setup(RequestDefinition req) throws IOException {
				req.init(meth, url);
				
				for (Map.Entry<String, String> header: headers.entrySet())
					req.setHeader(header.getKey(), header.getValue());
				
				if (timeout > 0)
					req.setTimeout(timeout);
				
				if (meth == HttpMethod.POST && !params.isEmpty()) {
					if (!hasBinaryAttachments) {
						String queryString = createQueryString();
						
						if (log.isLoggable(Level.FINER))
							log.finer("POST data is: " + queryString);
						
						// This is more efficient if we don't have any binary attachments
						req.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
						req.setContent(queryString.getBytes("utf-8"));
					} else {
						log.finer("POST contains binary data, sending multipart/form-data");
						
						// Binary attachments requires more complicated multipart/form-data format
						MultipartWriter writer = new MultipartWriter(req);
						writer.write(params);
					}
				}
			}
		});
	}
1004580
public static Map<String, List<String>> getResponseHeaders(String stringUrl,
      boolean followRedirects) throws IOException {
    URL url = new URL(stringUrl);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setInstanceFollowRedirects(followRedirects);
    
    InputStream is = conn.getInputStream();
    if ("gzip".equals(conn.getContentEncoding())) {
       is = new GZIPInputStream(is);
    }

    Map<String, List<String>> headers = new LinkedHashMap<String, List<String>>(conn.getHeaderFields());
    headers.put("X-Content", Arrays.asList(MyStreamUtils.readContent(is)));
    headers.put("X-URL", Arrays.asList(conn.getURL().toString()));
    headers.put("X-Status", Arrays.asList(String.valueOf(conn.getResponseCode())));
    
    return headers;
  }
642577
public static Request request(String url, String... headers) {
		Request.Builder request = new Request.Builder().url(url);
		if (headers != null) {
			int length = headers.length;
			checkArgument(length % 2 == 0, "headers length must be a multiple of two");
			for (int i = 0; i < length; i += 2) {
				request.addHeader(headers[i], headers[i + 1]);
			}
		}
		return request.build();
	}
1273283
@NotNull
	public HttpResponse withHeader(@NotNull HttpHeader header, @NotNull String value) {
		addHeader(header, value);
		return this;
	}
36716
public static String get(String url, Map<String, String> queryParas, Map<String, String> headers) {
		HttpURLConnection conn = null;
		try {
			conn = getHttpConnection(buildUrlWithQueryString(url, queryParas), GET, headers);
			conn.connect();
			return readResponseString(conn);
		}
		catch (Exception e) {
			throw new RuntimeException(e);
		}
		finally {
			if (conn != null) {
				conn.disconnect();
			}
		}
	}
1297572
public XcapResponse get(URI uri, Header[] additionalRequestHeaders,
			Credentials credentials) throws IOException {

		if (log.isDebugEnabled()) {
			log.debug("get(uri=" + uri + " , additionalRequestHeaders = ( "
					+ Arrays.toString(additionalRequestHeaders) + " ) )");
		}

		return execute(new HttpGet(uri), additionalRequestHeaders, credentials);
	}
174756
public void doHttpPost(String url, HttpResponse result, Map<String, Object> headers, String contentType) {
        httpClient.post(url, result, headers, contentType);
    }
21207
@Override
    public void addRequestHeader(Header header) {
        LOG.trace("HttpMethodBase.addRequestHeader(Header)");

        if (header == null) {
            LOG.debug("null header value ignored");
        } else {
            getRequestHeaderGroup().addHeader(header);
        }
    }
111007
public XcapResponse delete(URI uri, Header[] additionalRequestHeaders,
			Credentials credentials) throws IOException {

		if (log.isDebugEnabled()) {
			log.debug("delete(uri=" + uri + " , additionalRequestHeaders = ( "
					+ Arrays.toString(additionalRequestHeaders) + " ) )");
		}

		return execute(new HttpDelete(uri), additionalRequestHeaders,
				credentials);
	}
426061
@Override public Response intercept(Chain chain) throws IOException {
    final Request request = chain.request();

    return chain.proceed(request.newBuilder()
        .addHeader(name, value)
        .build());
  }
117099
public XcapResponse put(URI uri, String mimetype, String content,
			Header[] additionalRequestHeaders, Credentials credentials)
			throws IOException {

		if (log.isDebugEnabled()) {
			log.debug("put(uri=" + uri + ", mimetype=" + mimetype
					+ ", content=" + content
					+ " , additionalRequestHeaders = ( "
					+ Arrays.toString(additionalRequestHeaders) + " ) )");
		}

		final HttpPut request = new HttpPut(uri);
		setRequestEntity(request, content, mimetype);
		return execute(request, additionalRequestHeaders, credentials);

	}
260360
@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;
    }
675453
public static HttpResponse execute(final String url, final String method,
                                       final Map<String, Object> headers) {
        return execute(url, method, null, null, new HashMap<>(), headers);
    }
1141385
public HttpRequest buildHeadRequest(GenericUrl url) throws IOException {
    return buildRequest(HttpMethods.HEAD, url, null);
  }
1300703
public static VcfHeader header(final URL url) throws IOException {
        checkNotNull(url);
        try (BufferedReader reader = Resources.asCharSource(url, Charsets.UTF_8).openBufferedStream()) {
            return header(reader);
        }
    }