如何使用带有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
描述了对此的需求