Use the passed HTTP method to connect the {@link HttpClient}.

@param method the HTTP method to send

@return a {@link RequestSender} ready to finalize request and consume for response
188815
public RequestSender request(HttpMethod method) {
		Objects.requireNonNull(method, "method");
		TcpClient tcpConfiguration = tcpConfiguration().bootstrap(b -> HttpClientConfiguration.method(b, method));
		return new HttpClientFinalizer(tcpConfiguration);
	}
409864
public Object invokeMethod(String method, Object[] params) {
        log.debug("invokeMethod url: {}", (url + appendToUrl));
        IoBuffer resultBuffer = null;
        IoBuffer data = encodeInvoke(method, params);
        //setup POST
        HttpPost post = null;
        try {
            post = new HttpPost(url + appendToUrl);
            post.addHeader("Content-Type", CONTENT_TYPE);
            post.setEntity(new InputStreamEntity(data.asInputStream(), data.limit()));
            // execute the method
            HttpResponse response = client.execute(post);
            int code = response.getStatusLine().getStatusCode();
            log.debug("HTTP response code: {}", code);
            if (code / 100 != 2) {
                throw new RuntimeException("Didn't receive success from remoting server");
            } else {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    //fix for Trac #676
                    int contentLength = (int) entity.getContentLength();
                    //default the content length to 16 if post doesn't contain a good value
                    if (contentLength < 1) {
                        contentLength = 16;
                    }
                    // get the response as bytes
                    byte[] bytes = EntityUtils.toByteArray(entity);
                    resultBuffer = IoBuffer.wrap(bytes);
                    Object result = decodeResult(resultBuffer);
                    if (result instanceof RecordSet) {
                        // Make sure we can retrieve paged results
                        ((RecordSet) result).setRemotingClient(this);
                    }
                    return result;
                }
            }
        } catch (Exception ex) {
            log.error("Error while invoking remoting method: {}", method, ex);
            post.abort();
        } finally {
            if (resultBuffer != null) {
                resultBuffer.free();
                resultBuffer = null;
            }
            data.free();
            data = null;
        }
        return null;
    }
459511
function(method, params, payload) {
        var baseUrl   = (method.base_url || this.spec.base_url).replace(/(\/)$/, '');
        var headers   = {};
        for (var header in method.headers) {
            headers[header] = method.headers[header];
        }
        return simpleHttp.createRequest(this.httpClient, baseUrl + method.path, method.method, headers, params, payload);
    }
169199
<O extends Message> JsonResponseFuture<O> newProvisionalResponse(ClientMethod<O> method) {
    long requestId = RANDOM.nextLong();
    JsonResponseFuture<O> outputFuture = new JsonResponseFuture<>(requestId, method);
    inFlightRequests.put(requestId, outputFuture);
    return outputFuture;
  }
2306
protected Operation httpOp(String method, HttpUrl url) {
        return new Operation(httpClient).method(method).httpUrl(url);
    }
1122005
public static RequestBuilder newRequest(String method, String url) {
        return new RequestBuilder().method(method).url(url);
    }
974209
@SneakyThrows
    public BaseHttpServletRequestXMLMessageDecoder getInstance(final HttpMethod method) {
        val decoder = get(method);
        return (BaseHttpServletRequestXMLMessageDecoder) BeanUtils.cloneBean(decoder);
    }
502884
@SuppressWarnings("unchecked")
    protected <T, P extends Promise<T>> P send(HttpMethod method, Class<T> resultType) {
        setMethod(method);
        return (P) dispatcher.dispatch(processor.process(build()), resultType);
    }
361580
private HttpURLConnection openConnection(String uri, String method) {
        for (String host : hosts) {
            try {
                URL templateUrl = new URL("http://" + host  + uri);
                HttpURLConnection connection = ( HttpURLConnection ) templateUrl.openConnection();
                connection.setRequestMethod(method);
                connection.setConnectTimeout(timeout);
                connection.setUseCaches(false);
                if (method.equalsIgnoreCase("POST") || method.equalsIgnoreCase("PUT")) {
                    connection.setDoOutput(true);
                }
                connection.connect();

                return connection;
            } catch (IOException e) {
                LOGGER.error("Error connecting to {}: {}", host, e);
            }
        }

        return null;
    }
1100510
private void doExecute(HttpMethod method) throws IOException {
        long start = System.currentTimeMillis();
        try {
            client.executeMethod(method);
            afterExecute(method);
        } finally {
            stats.netTotalTime += (System.currentTimeMillis() - start);
            closeAuthSchemeQuietly(method);
        }
    }
247797
protected TransportResult doit(String method, URI uri, String payload){
		HttpURLConnection httpConnection = null;
		try {
			URL url = uri.toURL();
			URLConnection connection = url.openConnection();

			if (connection instanceof HttpURLConnection) {
				httpConnection = (HttpURLConnection) connection;

				httpConnection.setRequestMethod(method);
//				httpConnection.setRequestProperty("Content-Language", "en-US");

				httpConnection.setRequestProperty(apiAuthHeaderKey, getApitraryApi().getApiKey());
				httpConnection.setRequestProperty("Accept", contentType);
				httpConnection.setRequestProperty("Content-Type", contentType);

				httpConnection.setUseCaches(false);
				httpConnection.setDoInput(true);
				httpConnection.setDoOutput(payload!=null);

				log.debug(method+" "+ httpConnection.getURL()+(payload!=null?"application/json: "+payload:""));
				
				if(payload!=null){
					byte[] bytes = payload.getBytes();
					httpConnection.setRequestProperty("Content-Length", "" + Integer.toString(bytes.length));
					DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
					wr.writeBytes(payload);
					wr.flush();
					wr.close();
				}

				return new JavaNetClientTransportResult(httpConnection);
			} else {
				throw new ApiTransportException("Connection is not an HTTPConnection");
			}
		} catch (IOException ioe) {
			throw new ApiTransportException(ioe);
		}
	}
412870
public <T> T send(Request<T> request) {

		if (request == null) {
			throw new CommunicationErrorException("Request cannot be null.");
		}
		RequestUtil.validate(request);

		@SuppressWarnings("unchecked")
		T response = (T) dispatchByMethod(request);

		return response;
	}
557323
@Override
    public void invoke(String method, IPendingServiceCallback callback) {
        log.debug("invoke method: {} params {} callback {}", new Object[] { method, callback });
        // get it from the conn manager
        if (conn != null) {
            conn.invoke(method, callback);
        } else {
            log.info("Connection was null");
            PendingCall result = new PendingCall(method);
            result.setStatus(Call.STATUS_NOT_CONNECTED);
            callback.resultReceived(result);
        }
    }
1243945
private HttpExecutor createHttpExecutor(RequestMethodHolder requestMethodHolder) {
    HttpExecutor executor;
    if (customHttpClient == null) {
      executor = executorFactory.getHttpExecutor(requestMethodHolder.getBodyType());
    } else {
      executor = executorFactory.getHttpExecutor(requestMethodHolder.getBodyType(), customHttpClient);
    }
    executor.setCharset(charset);
    executor.setProxy(this.proxy);
    executor.setTimeout(timeout.socketTimeout, timeout.connectTimeout);
    return executor;
  }
1238860
private void applyConnectionParams(final HttpMethod method) throws IOException {
        int timeout = 0;
        // see if a timeout is given for this method
        Object param = method.getParams().getParameter(HttpMethodParams.SO_TIMEOUT);
        if (param == null) {
            // if not, use the default value
            param = this.conn.getParams().getParameter(HttpConnectionParams.SO_TIMEOUT);
        }
        if (param != null) {
            timeout = ((Integer)param).intValue();
        }
        this.conn.setSocketTimeout(timeout);                    
    }
721650
public final String callMethod(String method) {
    parent.assertConnected();
    return debugger.callFunctionOnObject(method, objectId);
  }
1098233
private <I extends Message, O extends Message> ListenableFuture<JsonRpcResponse> invoke(
      ServerMethod<I, O> method, JsonObject parameter, JsonElement id) {
    I request;
    try {
      request = (I) Messages.fromJson(method.inputBuilder(), parameter);
    } catch (Exception e) {
      serverLogger.logServerFailure(method, e);
      SettableFuture<JsonRpcResponse> future = SettableFuture.create();
      future.setException(e);
      return future;
    }
    ListenableFuture<O> response = method.invoke(request);
    return Futures.transform(response, new JsonConverter(id), TRANSFORM_EXECUTOR);
  }