泽西客户端/ Apache连接器:如何删除拦截器?

时间:2019-05-17 06:37:10

标签: apache-httpclient-4.x jersey-client

如何使用带有Apache-Connector的Jersey-Client删除请求拦截器? 我需要删除默认的RequestContent拦截器。

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.glassfish.jersey.apache.connector.ApacheClientProperties;
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;

......

    final ClientConfig clientConfig = new ClientConfig();

    connectionManager = new PoolingHttpClientConnectionManager();
    connectionManager.setMaxTotal(2);
    connectionManager.setDefaultMaxPerRoute(1);

    clientConfig.property(ClientProperties.CONNECT_TIMEOUT, 60_000);
    clientConfig.property(ClientProperties.READ_TIMEOUT, 60_000);
    clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, connectionManager);
    clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER_SHARED, false);
    clientConfig.connectorProvider(new ApacheConnectorProvider());

    client = ClientBuilder
            .newBuilder()
            .withConfig(clientConfig)
            .sslContext(SSLContextBuilder.createdTrustedAll())
            .hostnameVerifier((hostname, session) -> true)
            .build();

此处Jersey http client: put request with custom Content-Length

描述了对此的需求

0 个答案:

没有答案