Creates the tcpClient with proper handler.

@return the bound request builder
@throws HttpRequestCreateException
the http request create exception
489512
public ClientBootstrap bootStrapTcpClient()
            throws HttpRequestCreateException {

        ClientBootstrap tcpClient = null;
        try {

            // Configure the client.
            tcpClient = new ClientBootstrap(tcpMeta.getChannelFactory());

            // Configure the pipeline factory.
            tcpClient.setPipelineFactory(new MyPipelineFactory(TcpUdpSshPingResourceStore.getInstance().getTimer(),
                    this, tcpMeta.getTcpIdleTimeoutSec())
            );

            tcpClient.setOption("connectTimeoutMillis",
                    tcpMeta.getTcpConnectTimeoutMillis());
            tcpClient.setOption("tcpNoDelay", true);
          // tcpClient.setOption("keepAlive", true);

        } catch (Exception t) {
            throw new TcpUdpRequestCreateException(
                    "Error in creating request in Tcpworker. "
                            + " If tcpClient is null. Then fail to create.", t);
        }

        return tcpClient;

    }
522007
public Client<? extends Options, ? extends OptionsBuilder, ? extends RequestBuilder> newClient() {
        if (clientClassName == null) {
            return new DefaultClient();
        } else {
            try {
                return (Client) Thread.currentThread().getContextClassLoader().loadClass(clientClassName).newInstance();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
818537
public static MfClientHttpRequestFactory createFactoryWrapper(
            final MfClientHttpRequestFactory requestFactory,
            final UriMatchers matchers, final Map<String, List<String>> headers) {
        return new AbstractMfClientHttpRequestFactoryWrapper(requestFactory, matchers, false) {
            @Override
            protected ClientHttpRequest createRequest(
                    final URI uri,
                    final HttpMethod httpMethod,
                    final MfClientHttpRequestFactory requestFactory) throws IOException {
                final ClientHttpRequest request = requestFactory.createRequest(uri, httpMethod);
                request.getHeaders().putAll(headers);
                return request;
            }
        };
    }
79809
private HttpClient createPooledClient() {
    HttpParams connMgrParams = new BasicHttpParams();
    
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme(HTTP_SCHEME, PlainSocketFactory.getSocketFactory(), HTTP_PORT));
    schemeRegistry.register(new Scheme(HTTPS_SCHEME, SSLSocketFactory.getSocketFactory(), HTTPS_PORT));
    
    // All connections will be to the same endpoint, so no need for per-route configuration.
    // TODO See how this does in the presence of redirects.
    ConnManagerParams.setMaxTotalConnections(connMgrParams, poolSize);
    ConnManagerParams.setMaxConnectionsPerRoute(connMgrParams, new ConnPerRouteBean(poolSize));
    
    ClientConnectionManager ccm = new ThreadSafeClientConnManager(connMgrParams, schemeRegistry);
    
    HttpParams httpParams = new BasicHttpParams();
    HttpProtocolParams.setUseExpectContinue(httpParams, false);
    ConnManagerParams.setTimeout(httpParams, acquireTimeout * 1000);
    return new DefaultHttpClient(ccm, httpParams);
  }
386501
public HttpClient createClient(int maxConnPerRoute, int connTimeoutMillis, int soTimeoutMillis, @Nullable String proxyHostAnPort) {
		Registry<ConnectionSocketFactory> defaultRegistry = RegistryBuilder
			.<ConnectionSocketFactory> create()
			.register("http", PlainConnectionSocketFactory.getSocketFactory())
			.register("https", SSLConnectionSocketFactory.getSocketFactory())
			.build();
		PoolingHttpClientConnectionManager connMgr = new PoolingHttpClientConnectionManager(defaultRegistry);
			connMgr.setDefaultMaxPerRoute(maxConnPerRoute);
		RequestConfig rCfg = RequestConfig.custom()
			.setConnectTimeout(connTimeoutMillis)
			.setSocketTimeout(soTimeoutMillis)
			.build();
		HttpClientBuilder hcb = HttpClientBuilder.create()
			.setConnectionManager(connMgr)
			.setDefaultRequestConfig(rCfg);
		if (proxyHostAnPort == null) {
			// do something?
		} else if("jvm".equalsIgnoreCase(proxyHostAnPort)) {
			SystemDefaultRoutePlanner rp = new SystemDefaultRoutePlanner(ProxySelector.getDefault());
			hcb.setRoutePlanner(rp);
		} else {
			String[] hostAndPort = proxyHostAnPort.split(":");
			Check.illegalargument.assertTrue(hostAndPort.length < 3, "wrong hostAndPort:"+proxyHostAnPort);
			String host = hostAndPort[0];
			int port = 80;
			if (hostAndPort.length > 1) {
				port = Integer.valueOf(hostAndPort[1]);
			}
			HttpHost proxy = new HttpHost(host, port);
			hcb.setProxy(proxy);
		}
		HttpClient httpClient = hcb.build();
		return httpClient;
	}
860144
public static WebsocketClientTransport create(String bindAddress, int port) {
    Objects.requireNonNull(bindAddress, "bindAddress must not be null");

    TcpClient client = TcpClient.create().host(bindAddress).port(port);
    return create(client);
  }
919173
Function<TcpClient, TcpClient> build() {
		HttpResponseDecoderSpec decoder = new HttpResponseDecoderSpec();
		decoder.initialBufferSize = initialBufferSize;
		decoder.maxChunkSize = maxChunkSize;
		decoder.maxHeaderSize = maxHeaderSize;
		decoder.maxInitialLineLength = maxInitialLineLength;
		decoder.validateHeaders = validateHeaders;
		decoder.failOnMissingResponse = failOnMissingResponse;
		decoder.parseHttpAfterConnectRequest = parseHttpAfterConnectRequest;
		return tcp -> tcp.bootstrap(b -> HttpClientConfiguration.decoder(b, decoder));
	}
638944
protected <T extends HttpRequestBase> T createHttpRequest(Q request) {
    T httpRequest = createHttpRequestBase(request);

    applyHeaders(httpRequest, request.getHeaders());

    applyPayload(httpRequest, request);

    return httpRequest;
  }
1210591
public TCPPort createEndPoint() throws ChannelException {
        TCPPort tcpPort = super.createEndPoint();
        try {
            this.asyncChannelGroup = findOrCreateACG();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "AioTCPChannel created completion port for inbound connections on host " + getConfig().getHostname() + ", port " + getConfig().getPort()
                             + ", completionPort = " + this.asyncChannelGroup.getCompletionPort());
            }

        } catch (AsyncException ae) {
            ChannelException ce = new ChannelException("Error creating async channel group ");
            ce.initCause(ae);
            throw ce;
        }
        return tcpPort;
    }
1138765
private SailthruHttpClient create() {
        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, DEFAULT_ENCODING);
        HttpProtocolParams.setUserAgent(params, DEFAULT_USER_AGENT);
        HttpProtocolParams.setUseExpectContinue(params, true);

        HttpConnectionParams.setConnectionTimeout(params, sailthruHttpClientConfiguration.getConnectionTimeout());
        HttpConnectionParams.setSoTimeout(params, sailthruHttpClientConfiguration.getSoTimeout());
        HttpConnectionParams.setSoReuseaddr(params, sailthruHttpClientConfiguration.getSoReuseaddr());
        HttpConnectionParams.setTcpNoDelay(params, sailthruHttpClientConfiguration.getTcpNoDelay());

        SchemeRegistry schemeRegistry = new SchemeRegistry();
        schemeRegistry.register(getScheme());

        ThreadSafeClientConnManager connManager = new ThreadSafeClientConnManager(schemeRegistry);
        return new SailthruHttpClient(connManager, params);
    }
1062205
public static WebsocketClientTransport create(TcpClient client) {
    Objects.requireNonNull(client, "client must not be null");

    return create(HttpClient.from(client), DEFAULT_PATH);
  }
991623
static RequestCreator<JmxListRequest> newCreator() {
        return new RequestCreator<JmxListRequest>() {
            /** {@inheritDoc} */
            public JmxListRequest create(Stack<String> pStack, ProcessingParameters pParams) throws MalformedObjectNameException {
                return new JmxListRequest(
                        prepareExtraArgs(pStack), // path
                        pParams);
            }

            /** {@inheritDoc} */
            public JmxListRequest create(Map<String, ?> requestMap, ProcessingParameters pParams)
                    throws MalformedObjectNameException {
                return new JmxListRequest(requestMap,pParams);
            }
        };
    }
1302132
@Override
    protected BasicHttpProcessor createHttpProcessor() {
        final BasicHttpProcessor parentHttpProcessor = super.createHttpProcessor();
        
        for (int i = 0; i < parentHttpProcessor.getRequestInterceptorCount(); i++) {
            final HttpRequestInterceptor requestInterceptor = parentHttpProcessor.getRequestInterceptor(i);
            
            //Replace the existing RequestContent interceptor with a version that sets overwrite=true
            if (requestInterceptor instanceof RequestContent) {
                parentHttpProcessor.removeRequestInterceptorByClass(RequestContent.class);
                parentHttpProcessor.addInterceptor(new RequestContent(true), i);
                break;
            }
        }
        
        return parentHttpProcessor;
    }
505996
private HttpURLConnection createConnection() {
        String urlString = getRequestInfo().getRequestUrl().toString();
        if( getRequestInfo().requestMethod == null ) {
            throw new KieServerHttpRequestException("Please specify (and execute?) a HTTP method first.");
        }
        try {
            final HttpURLConnection connection;
            if( this.httpProxyHost != null ) {
                Proxy proxy = new Proxy(HTTP, new InetSocketAddress(this.httpProxyHost, this.httpProxyPort));
                connection = CONNECTION_FACTORY.create(getRequestInfo().getRequestUrl(), proxy);
            } else {
                connection = CONNECTION_FACTORY.create(getRequestInfo().getRequestUrl());
            }
            // support for localhost and https
            if (getRequestInfo().getRequestUrl().getProtocol().equalsIgnoreCase("https") && getRequestInfo().getRequestUrl().getHost().equalsIgnoreCase("localhost")) {
                ((HttpsURLConnection) connection).setHostnameVerifier(new HostnameVerifier(){

                    public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
                        if (hostname.equalsIgnoreCase("localhost")) {
                            return true;
                        }
                        return false;
                    }
                });
            }

            connection.setRequestMethod(getRequestInfo().requestMethod);
            return connection;
        } catch( IOException ioe ) {
            throw new KieServerHttpRequestException("Unable to create (" + getRequestInfo().requestMethod + ") connection to '"
                    + urlString + "'", ioe);
        }
    }
1137463
public Request<T> build()
    {
        MultiMap headers = resolveHeaders();
        MultiMap parameters = resolveParameters();

        parameters.add("version",Integer.toString(version));

        Request<T> request = new Request<T>();
        request.setEntityName(entityName);
        request.setEntityType(objectType);
        request.setHeaders(headers);
        request.setParameters(parameters);

        return request;
    }
231157
public static HttpBuilder request(String protocol, String host, Integer port, String path) {
		return defaults(createClient().request(protocol, host, port, path));
	}
1251091
public CloseableHttpClient createHttpConnection() {
    LOG.trace("HTTP build new connection based on connection pool");
    return HttpClients
            .custom()
            .setRetryHandler(getRetryHandler())
            .setConnectionManager(connectionPool)
            .setDefaultRequestConfig(rConfig)
            .setKeepAliveStrategy(myStrategy)
            .build();
  }