Upgraded HttpCore to version 5.3-alpha2

This commit is contained in:
Oleg Kalnichevski 2024-02-01 14:58:56 +01:00
parent 661589e386
commit 8a7f707a61
36 changed files with 105 additions and 142 deletions

View File

@ -27,7 +27,6 @@
package org.apache.hc.client5.http.cache;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
@ -69,7 +68,7 @@ public class HttpCacheContext extends HttpClientContext {
}
public static HttpCacheContext create() {
return new HttpCacheContext(new BasicHttpContext());
return new HttpCacheContext(new HttpClientContext());
}
public HttpCacheContext(final HttpContext context) {

View File

@ -74,7 +74,6 @@ import org.apache.hc.core5.http.message.RequestLine;
import org.apache.hc.core5.http.nio.AsyncDataConsumer;
import org.apache.hc.core5.http.nio.AsyncEntityProducer;
import org.apache.hc.core5.http.nio.CapacityChannel;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.http.support.BasicRequestBuilder;
import org.apache.hc.core5.net.URIAuthority;
import org.apache.hc.core5.util.Args;
@ -206,8 +205,8 @@ class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
public AsyncDataConsumer handleResponse(
final HttpResponse response,
final EntityDetails entityDetails) throws HttpException, IOException {
context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
context.setRequest(request);
context.setResponse(response);
return asyncExecCallback.handleResponse(response, entityDetails);
}

View File

@ -26,7 +26,6 @@
*/
package org.apache.hc.client5.http.impl.cache;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@ -89,12 +88,12 @@ class CacheControlHeaderParser {
/**
* The set of characters that can delimit a token in the header.
*/
private static final BitSet TOKEN_DELIMS = Tokenizer.INIT_BITSET(EQUAL_CHAR, ',');
private static final Tokenizer.Delimiter TOKEN_DELIMS = Tokenizer.delimiters(EQUAL_CHAR, ',');
/**
* The set of characters that can delimit a value in the header.
*/
private static final BitSet VALUE_DELIMS = Tokenizer.INIT_BITSET(EQUAL_CHAR, ',');
private static final Tokenizer.Delimiter VALUE_DELIMS = Tokenizer.delimiters(EQUAL_CHAR, ',');
/**
* The token parser used to extract values from the header.

View File

@ -66,7 +66,6 @@ import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
import org.apache.hc.core5.http.message.RequestLine;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.net.URIAuthority;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.ByteArrayBuffer;
@ -133,8 +132,8 @@ class CachingExec extends CachingExecBase implements ExecChainHandler {
final HttpHost target = authority != null ? new HttpHost(scheme, authority) : route.getTargetHost();
final ClassicHttpResponse response = doExecute(target, request, scope, chain);
context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
context.setRequest(request);
context.setResponse(response);
return response;
}

View File

@ -79,7 +79,7 @@ public abstract class AbstractSimpleServerExchangeHandler extends AbstractServer
final SimpleHttpRequest request,
final AsyncServerRequestHandler.ResponseTrigger responseTrigger,
final HttpContext context) throws HttpException, IOException {
final SimpleHttpResponse response = handle(request, HttpCoreContext.adapt(context));
final SimpleHttpResponse response = handle(request, HttpCoreContext.cast(context));
final SimpleBody body = response.getBody();
final AsyncEntityProducer entityProducer;
if (body != null) {

View File

@ -42,7 +42,6 @@ import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.config.Http1Config;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.net.URIAuthority;
@ -207,7 +206,7 @@ public class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTes
connManager.setDefaultMaxPerRoute(maxConn);
// Bottom of the pool : a *keep alive* connection to Route 1.
final HttpContext context1 = new BasicHttpContext();
final HttpContext context1 = new HttpClientContext();
context1.setAttribute("user", "stuff");
final SimpleHttpRequest request1 = SimpleRequestBuilder.get()
@ -227,7 +226,7 @@ public class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTes
// Send a very simple HTTP get (it MUST be simple, no auth, no proxy, no 302, no 401, ...)
// Send it to another route. Must be a keepalive.
final HttpContext context2 = new BasicHttpContext();
final HttpContext context2 = new HttpClientContext();
final SimpleHttpRequest request2 = SimpleRequestBuilder.get()
.setScheme(target.getSchemeName())
@ -250,7 +249,7 @@ public class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTes
// So the ConnPoolByRoute will need to kill one connection (it is maxed out globally).
// The killed conn is the oldest, which means the first HTTPGet ([localhost][stuff]).
// When this happens, the RouteSpecificPool becomes empty.
final HttpContext context3 = new BasicHttpContext();
final HttpContext context3 = new HttpClientContext();
final SimpleHttpRequest request3 = SimpleRequestBuilder.get()
.setHttpHost(target)

View File

@ -36,6 +36,7 @@ import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.io.ConnectionEndpoint;
import org.apache.hc.client5.http.io.LeaseRequest;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.testing.classic.RandomHandler;
import org.apache.hc.client5.testing.sync.extension.TestClientResources;
import org.apache.hc.core5.http.ClassicHttpRequest;
@ -47,7 +48,6 @@ import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
import org.apache.hc.core5.http.io.HttpClientConnection;
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.protocol.HttpProcessor;
@ -128,7 +128,7 @@ public class TestConnectionManagement {
final String uri = "/random/" + rsplen;
final ClassicHttpRequest request = new BasicClassicHttpRequest("GET", target, uri);
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final LeaseRequest leaseRequest1 = connManager.lease("id1", route, null);
final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS);
@ -192,7 +192,7 @@ public class TestConnectionManagement {
final String uri = "/random/" + rsplen;
final ClassicHttpRequest request = new BasicClassicHttpRequest("GET", target, uri);
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final LeaseRequest leaseRequest1 = connManager.lease("id1", route, null);
final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS);
@ -258,7 +258,7 @@ public class TestConnectionManagement {
connManager.setMaxTotal(1);
final HttpRoute route = new HttpRoute(target, null, false);
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final LeaseRequest leaseRequest1 = connManager.lease("id1", route, null);
final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS);
@ -311,7 +311,7 @@ public class TestConnectionManagement {
connManager.setMaxTotal(1);
final HttpRoute route = new HttpRoute(target, null, false);
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final LeaseRequest leaseRequest1 = connManager.lease("id1", route, null);
final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS);

View File

@ -45,6 +45,7 @@ import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy;
import org.apache.hc.client5.http.ssl.HostnameVerificationPolicy;
import org.apache.hc.client5.http.ssl.HttpsSupport;
@ -54,8 +55,6 @@ import org.apache.hc.client5.testing.SSLTestContexts;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.ssl.SSLContexts;
import org.apache.hc.core5.ssl.TrustStrategy;
@ -105,7 +104,7 @@ public class TestDefaultClientTlsStrategy {
// @formatter:on
this.server.start();
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final TestX509HostnameVerifier hostVerifier = new TestX509HostnameVerifier();
final TlsSocketStrategy tlsStrategy = new DefaultClientTlsStrategy(
SSLTestContexts.createClientSSLContext(), hostVerifier);
@ -134,7 +133,7 @@ public class TestDefaultClientTlsStrategy {
// @formatter:on
this.server.start();
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final TlsSocketStrategy tlsStrategy = new DefaultClientTlsStrategy(SSLTestContexts.createClientSSLContext());
final HttpHost target = new HttpHost("https", "localhost", server.getLocalPort());
try (final Socket socket = new Socket(target.getHostName(), target.getPort())) {
@ -160,7 +159,7 @@ public class TestDefaultClientTlsStrategy {
// @formatter:on
this.server.start();
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final TestX509HostnameVerifier hostVerifier = new TestX509HostnameVerifier();
final TlsSocketStrategy tlsStrategy = new DefaultClientTlsStrategy(
SSLTestContexts.createClientSSLContext(), hostVerifier);
@ -190,7 +189,7 @@ public class TestDefaultClientTlsStrategy {
// @formatter:on
this.server.start();
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final TestX509HostnameVerifier hostVerifier = new TestX509HostnameVerifier();
final TlsSocketStrategy tlsStrategy = new DefaultClientTlsStrategy(
SSLTestContexts.createClientSSLContext(), hostVerifier);
@ -222,7 +221,7 @@ public class TestDefaultClientTlsStrategy {
// @formatter:on
this.server.start();
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
// Use default SSL context
final SSLContext defaultSslContext = SSLContexts.createDefault();
@ -255,7 +254,7 @@ public class TestDefaultClientTlsStrategy {
// @formatter:on
this.server.start();
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
// @formatter:off
final SSLContext sslContext = SSLContexts.custom()
@ -288,7 +287,7 @@ public class TestDefaultClientTlsStrategy {
// @formatter:on
this.server.start();
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final TlsSocketStrategy tlsStrategy = new DefaultClientTlsStrategy(
SSLTestContexts.createClientSSLContext());
final HttpHost target = new HttpHost("https", "localhost", server.getLocalPort());
@ -340,7 +339,7 @@ public class TestDefaultClientTlsStrategy {
// @formatter:on
this.server.start();
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final TlsSocketStrategy tlsStrategy = new DefaultClientTlsStrategy(
SSLTestContexts.createClientSSLContext());
final HttpHost target = new HttpHost("https", "localhost", server.getLocalPort());
@ -370,7 +369,7 @@ public class TestDefaultClientTlsStrategy {
SSLTestContexts.createClientSSLContext(),
HostnameVerificationPolicy.CLIENT,
HttpsSupport.getDefaultHostnameVerifier());
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final SSLSocket upgradedSocket = tlsStrategy.upgrade(
socket,
target1.getHostName(),
@ -388,7 +387,7 @@ public class TestDefaultClientTlsStrategy {
SSLTestContexts.createClientSSLContext(),
HostnameVerificationPolicy.CLIENT,
HttpsSupport.getDefaultHostnameVerifier());
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
Assertions.assertThrows(SSLPeerUnverifiedException.class, () ->
tlsStrategy.upgrade(
socket,
@ -403,7 +402,7 @@ public class TestDefaultClientTlsStrategy {
SSLTestContexts.createClientSSLContext(),
HostnameVerificationPolicy.CLIENT,
NoopHostnameVerifier.INSTANCE);
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final SSLSocket upgradedSocket = tlsStrategy.upgrade(
socket,
target1.getHostName(),
@ -431,7 +430,7 @@ public class TestDefaultClientTlsStrategy {
SSLTestContexts.createClientSSLContext(),
HostnameVerificationPolicy.BUILTIN,
NoopHostnameVerifier.INSTANCE);
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final SSLSocket upgradedSocket = tlsStrategy.upgrade(
socket,
target1.getHostName(),
@ -449,7 +448,7 @@ public class TestDefaultClientTlsStrategy {
SSLTestContexts.createClientSSLContext(),
HostnameVerificationPolicy.BUILTIN,
NoopHostnameVerifier.INSTANCE);
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
Assertions.assertThrows(SSLHandshakeException.class, () ->
tlsStrategy.upgrade(
socket,

View File

@ -43,7 +43,6 @@ import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.io.HttpRequestHandler;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.testing.classic.ClassicTestServer;
import org.apache.hc.core5.util.Timeout;
@ -217,7 +216,7 @@ public class TestStatefulConnManagement {
);
// Bottom of the pool : a *keep alive* connection to Route 1.
final HttpContext context1 = new BasicHttpContext();
final HttpContext context1 = new HttpClientContext();
context1.setAttribute("user", "stuff");
client.execute(target, new HttpGet("/"), context1, response -> {
EntityUtils.consume(response.getEntity());
@ -232,7 +231,7 @@ public class TestStatefulConnManagement {
// Send a very simple HTTP get (it MUST be simple, no auth, no proxy, no 302, no 401, ...)
// Send it to another route. Must be a keepalive.
final HttpContext context2 = new BasicHttpContext();
final HttpContext context2 = new HttpClientContext();
client.execute(new HttpHost("127.0.0.1", server.getPort()), new HttpGet("/"), context2, response -> {
EntityUtils.consume(response.getEntity());
return null;
@ -248,7 +247,7 @@ public class TestStatefulConnManagement {
// So the ConnPoolByRoute will need to kill one connection (it is maxed out globally).
// The killed conn is the oldest, which means the first HTTPGet ([localhost][stuff]).
// When this happens, the RouteSpecificPool becomes empty.
final HttpContext context3 = new BasicHttpContext();
final HttpContext context3 = new HttpClientContext();
client.execute(target, new HttpGet("/"), context3, response -> {
EntityUtils.consume(response.getEntity());
return null;

View File

@ -38,7 +38,6 @@ import org.apache.hc.client5.http.impl.DefaultSchemePortResolver;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
/**
* {@link HttpClientContext} builder.
@ -103,7 +102,7 @@ public class ContextBuilder extends AbstractClientContextBuilder<HttpClientConte
@Override
protected HttpClientContext createContext() {
return new HttpClientContext(new BasicHttpContext());
return new HttpClientContext();
}
}

View File

@ -74,7 +74,6 @@ import org.apache.hc.core5.http.nio.CapacityChannel;
import org.apache.hc.core5.http.nio.DataStreamChannel;
import org.apache.hc.core5.http.nio.RequestChannel;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.util.Args;
import org.slf4j.Logger;
@ -442,7 +441,7 @@ public final class AsyncConnectExec implements AsyncExecChainHandler {
public void consumeResponse(final HttpResponse response,
final EntityDetails entityDetails,
final HttpContext httpContext) throws HttpException, IOException {
clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
clientContext.setResponse(response);
proxyHttpProcessor.process(response, entityDetails, clientContext);
final int status = response.getCode();
@ -547,7 +546,7 @@ public final class AsyncConnectExec implements AsyncExecChainHandler {
final EndpointInfo endpointInfo = execRuntime.getEndpointInfo();
if (endpointInfo != null) {
clientContext.setProtocolVersion(endpointInfo.getProtocol());
clientContext.setAttribute(HttpCoreContext.SSL_SESSION, endpointInfo.getSslSession());
clientContext.setSSLSession(endpointInfo.getSslSession());
}
try {
chain.proceed(request, entityProducer, scope, asyncExecCallback);

View File

@ -55,7 +55,6 @@ import org.apache.hc.core5.http.nio.CapacityChannel;
import org.apache.hc.core5.http.nio.DataStreamChannel;
import org.apache.hc.core5.http.nio.RequestChannel;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.util.Args;
import org.slf4j.Logger;
@ -128,7 +127,7 @@ public class H2AsyncMainClientExec implements AsyncExecChainHandler {
public void produceRequest(final RequestChannel channel, final HttpContext context) throws HttpException, IOException {
clientContext.setAttribute(HttpClientContext.HTTP_ROUTE, route);
clientContext.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
clientContext.setRequest(request);
httpProcessor.process(request, entityProducer, clientContext);
channel.sendRequest(request, entityProducer, context);
@ -154,7 +153,7 @@ public class H2AsyncMainClientExec implements AsyncExecChainHandler {
final EntityDetails entityDetails,
final HttpContext context) throws HttpException, IOException {
clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
clientContext.setResponse(response);
httpProcessor.process(response, entityDetails, clientContext);
entityConsumerRef.set(asyncExecCallback.handleResponse(response, entityDetails));

View File

@ -63,7 +63,6 @@ import org.apache.hc.core5.http.nio.CapacityChannel;
import org.apache.hc.core5.http.nio.DataStreamChannel;
import org.apache.hc.core5.http.nio.RequestChannel;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.TimeValue;
@ -150,7 +149,7 @@ class HttpAsyncMainClientExec implements AsyncExecChainHandler {
final HttpContext context) throws HttpException, IOException {
clientContext.setAttribute(HttpClientContext.HTTP_ROUTE, route);
clientContext.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
clientContext.setRequest(request);
httpProcessor.process(request, entityProducer, clientContext);
channel.sendRequest(request, entityProducer, context);
@ -238,7 +237,7 @@ class HttpAsyncMainClientExec implements AsyncExecChainHandler {
final EntityDetails entityDetails,
final HttpContext context) throws HttpException, IOException {
clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
clientContext.setResponse(response);
httpProcessor.process(response, entityDetails, clientContext);
entityConsumerRef.set(asyncExecCallback.handleResponse(response, entityDetails));

View File

@ -28,7 +28,6 @@
package org.apache.hc.client5.http.impl.auth;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
import org.apache.hc.client5.http.auth.AuthChallenge;
@ -55,11 +54,9 @@ public class AuthChallengeParser {
private final static char COMMA_CHAR = ',';
private final static char EQUAL_CHAR = '=';
// IMPORTANT!
// These private static variables must be treated as immutable and never exposed outside this class
private static final BitSet TERMINATORS = Tokenizer.INIT_BITSET(BLANK, EQUAL_CHAR, COMMA_CHAR);
private static final BitSet DELIMITER = Tokenizer.INIT_BITSET(COMMA_CHAR);
private static final BitSet SPACE = Tokenizer.INIT_BITSET(BLANK);
private static final Tokenizer.Delimiter TERMINATORS = Tokenizer.delimiters(BLANK, EQUAL_CHAR, COMMA_CHAR);
private static final Tokenizer.Delimiter DELIMITER = Tokenizer.delimiters(COMMA_CHAR);
private static final Tokenizer.Delimiter SPACE = Tokenizer.delimiters(BLANK);
static class ChallengeInt {
@ -173,7 +170,7 @@ public class AuthChallengeParser {
while (!cursor.atEnd()) {
int pos = cursor.getPos();
char current = buf.charAt(pos);
if (TERMINATORS.get(current)) {
if (TERMINATORS.test(current)) {
// Here it gets really ugly
if (current == EQUAL_CHAR) {
// it can be a start of a parameter value or token68 padding

View File

@ -63,7 +63,6 @@ import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.util.Args;
import org.slf4j.Logger;
@ -190,7 +189,7 @@ public final class ConnectExec implements ExecChainHandler {
final EndpointInfo endpointInfo = execRuntime.getEndpointInfo();
if (endpointInfo != null) {
context.setProtocolVersion(endpointInfo.getProtocol());
context.setAttribute(HttpCoreContext.SSL_SESSION, endpointInfo.getSslSession());
context.setSSLSession(endpointInfo.getSslSession());
}
return chain.proceed(request, scope);

View File

@ -59,7 +59,6 @@ import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.io.ModalCloseable;
@ -147,7 +146,7 @@ class InternalHttpClient extends CloseableHttpClient implements Configurable {
Args.notNull(request, "HTTP request");
try {
final HttpClientContext localcontext = HttpClientContext.adapt(
context != null ? context : new BasicHttpContext());
context != null ? context : new HttpClientContext());
RequestConfig config = null;
if (request instanceof Configurable) {
config = ((Configurable) request).getConfig();

View File

@ -52,7 +52,6 @@ import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.ProtocolVersion;
import org.apache.hc.core5.http.message.RequestLine;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.io.CloseMode;
import org.apache.hc.core5.util.Args;
@ -115,7 +114,7 @@ public final class MainClientExec implements ExecChainHandler {
try {
// Run request protocol interceptors
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
context.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
context.setRequest(request);
httpProcessor.process(request, request.getEntity(), context);
@ -141,7 +140,7 @@ public final class MainClientExec implements ExecChainHandler {
},
context);
context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
context.setResponse(response);
httpProcessor.process(response, response.getEntity(), context);
Object userToken = context.getUserToken();

View File

@ -54,10 +54,8 @@ import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.impl.io.HttpRequestExecutor;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.http.protocol.RequestContent;
import org.apache.hc.core5.http.protocol.RequestTargetHost;
@ -121,7 +119,7 @@ public class MinimalHttpClient extends CloseableHttpClient {
request.setAuthority(new URIAuthority(target));
}
final HttpClientContext clientContext = HttpClientContext.adapt(
context != null ? context : new BasicHttpContext());
context != null ? context : new HttpClientContext());
RequestConfig config = null;
if (request instanceof Configurable) {
config = ((Configurable) request).getConfig();
@ -143,7 +141,7 @@ public class MinimalHttpClient extends CloseableHttpClient {
execRuntime.connectEndpoint(clientContext);
}
clientContext.setAttribute(HttpCoreContext.HTTP_REQUEST, request);
clientContext.setRequest(request);
clientContext.setAttribute(HttpClientContext.HTTP_ROUTE, route);
httpProcessor.process(request, request.getEntity(), clientContext);

View File

@ -69,10 +69,7 @@ import org.apache.hc.core5.http.io.HttpConnectionFactory;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.http.protocol.RequestTargetHost;
import org.apache.hc.core5.http.protocol.RequestUserAgent;
@ -148,7 +145,7 @@ public class ProxyClient {
proxy, false, TunnelType.TUNNELLED, LayerType.PLAIN);
final ManagedHttpClientConnection conn = this.connFactory.createConnection(null);
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
ClassicHttpResponse response;
final ClassicHttpRequest connect = new BasicClassicHttpRequest(Method.CONNECT, proxy, target.toHostString());
@ -157,7 +154,7 @@ public class ProxyClient {
credsProvider.setCredentials(new AuthScope(proxy), credentials);
// Populate the execution context
context.setAttribute(HttpCoreContext.HTTP_REQUEST, connect);
context.setRequest(connect);
context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
context.setAttribute(HttpClientContext.CREDS_PROVIDER, credsProvider);
context.setAttribute(HttpClientContext.AUTHSCHEME_REGISTRY, this.authSchemeRegistry);

View File

@ -29,7 +29,6 @@ package org.apache.hc.client5.http.impl.cookie;
import java.time.Instant;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@ -70,9 +69,9 @@ public class RFC6265CookieSpec implements CookieSpec {
// IMPORTANT!
// These private static variables must be treated as immutable and never exposed outside this class
private static final BitSet TOKEN_DELIMS = Tokenizer.INIT_BITSET(EQUAL_CHAR, PARAM_DELIMITER);
private static final BitSet VALUE_DELIMS = Tokenizer.INIT_BITSET(PARAM_DELIMITER);
private static final BitSet SPECIAL_CHARS = Tokenizer.INIT_BITSET(' ',
private static final Tokenizer.Delimiter TOKEN_DELIMS = Tokenizer.delimiters(EQUAL_CHAR, PARAM_DELIMITER);
private static final Tokenizer.Delimiter VALUE_DELIMS = Tokenizer.delimiters(PARAM_DELIMITER);
private static final Tokenizer.Delimiter SPECIAL_CHARS = Tokenizer.delimiters(' ',
DQUOTE_CHAR, COMMA_CHAR, PARAM_DELIMITER, ESCAPE_CHAR);
private final CookieAttributeHandler[] attribHandlers;
@ -257,10 +256,10 @@ public class RFC6265CookieSpec implements CookieSpec {
return containsChars(s, SPECIAL_CHARS);
}
boolean containsChars(final CharSequence s, final BitSet chars) {
boolean containsChars(final CharSequence s, final Tokenizer.Delimiter chars) {
for (int i = 0; i < s.length(); i++) {
final char ch = s.charAt(i);
if (chars.get(ch)) {
if (chars.test(ch)) {
return true;
}
}

View File

@ -44,7 +44,6 @@ import org.apache.hc.client5.http.cookie.CookieSpecFactory;
import org.apache.hc.client5.http.cookie.CookieStore;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.core5.util.Args;
@ -136,6 +135,7 @@ public class HttpClientContext extends HttpCoreContext {
*/
public static final String EXCHANGE_ID = "http.exchange-id";
@SuppressWarnings("deprecation")
public static HttpClientContext adapt(final HttpContext context) {
Args.notNull(context, "HTTP context");
if (context instanceof HttpClientContext) {
@ -145,7 +145,7 @@ public class HttpClientContext extends HttpCoreContext {
}
public static HttpClientContext create() {
return new HttpClientContext(new BasicHttpContext());
return new HttpClientContext();
}
public HttpClientContext(final HttpContext context) {

View File

@ -28,7 +28,6 @@
package org.apache.hc.client5.http.ssl;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;
import org.apache.hc.core5.http.NameValuePair;
@ -40,8 +39,8 @@ final class DistinguishedNameParser {
public final static DistinguishedNameParser INSTANCE = new DistinguishedNameParser();
private static final BitSet EQUAL_OR_COMMA_OR_PLUS = Tokenizer.INIT_BITSET('=', ',', '+');
private static final BitSet COMMA_OR_PLUS = Tokenizer.INIT_BITSET(',', '+');
private static final Tokenizer.Delimiter EQUAL_OR_COMMA_OR_PLUS = Tokenizer.delimiters('=', ',', '+');
private static final Tokenizer.Delimiter COMMA_OR_PLUS = Tokenizer.delimiters(',', '+');
private final Tokenizer tokenParser;
@ -49,11 +48,11 @@ final class DistinguishedNameParser {
this.tokenParser = new InternalTokenParser();
}
private String parseToken(final CharArrayBuffer buf, final Tokenizer.Cursor cursor, final BitSet delimiters) {
private String parseToken(final CharArrayBuffer buf, final Tokenizer.Cursor cursor, final Tokenizer.Delimiter delimiters) {
return tokenParser.parseToken(buf, cursor, delimiters);
}
private String parseValue(final CharArrayBuffer buf, final Tokenizer.Cursor cursor, final BitSet delimiters) {
private String parseValue(final CharArrayBuffer buf, final Tokenizer.Cursor cursor, final Tokenizer.Delimiter delimiters) {
return tokenParser.parseValue(buf, cursor, delimiters);
}
@ -100,7 +99,7 @@ final class DistinguishedNameParser {
public void copyUnquotedContent(
final CharSequence buf,
final Tokenizer.Cursor cursor,
final BitSet delimiters,
final Tokenizer.Delimiter delimiters,
final StringBuilder dst) {
int pos = cursor.getPos();
final int indexFrom = cursor.getPos();
@ -112,7 +111,7 @@ final class DistinguishedNameParser {
dst.append(current);
escaped = false;
} else {
if ((delimiters != null && delimiters.get(current))
if ((delimiters != null && delimiters.test(current))
|| Tokenizer.isWhitespace(current) || current == '\"') {
break;
} else if (current == '\\') {

View File

@ -30,9 +30,9 @@ import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
@ -90,7 +90,7 @@ public class ClientMultiThreadedExecution {
public GetThread(final CloseableHttpClient httpClient, final HttpGet httpget, final int id) {
this.httpClient = httpClient;
this.context = new BasicHttpContext();
this.context = new HttpClientContext();
this.httpget = httpget;
this.id = id;
}

View File

@ -32,8 +32,6 @@ import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.TimeValue;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -45,7 +43,7 @@ public class TestDefaultConnKeepAliveStrategy {
@Test
public void testIllegalResponseArg() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final HttpClientContext context = new HttpClientContext();
final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
Assertions.assertThrows(NullPointerException.class, () ->
keepAliveStrat.getKeepAliveDuration(null, context));

View File

@ -52,7 +52,6 @@ import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.message.BasicHttpResponse;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@ -87,7 +86,7 @@ public class TestHttpAuthenticator {
this.authScheme = Mockito.mock(CacheableAuthState.class, Mockito.withSettings()
.defaultAnswer(Answers.CALLS_REAL_METHODS));
Mockito.when(this.authScheme.isChallengeComplete()).thenReturn(Boolean.TRUE);
this.context = new BasicHttpContext();
this.context = new HttpClientContext();
this.defaultHost = new HttpHost("localhost", 80);
this.credentialsProvider = Mockito.mock(CredentialsProvider.class);
this.context.setAttribute(HttpClientContext.CREDS_PROVIDER, this.credentialsProvider);

View File

@ -37,7 +37,7 @@ import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.Credentials;
import org.apache.hc.client5.http.auth.StandardAuthScheme;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
@ -59,7 +59,7 @@ public class TestSystemDefaultCredentialsProvider {
new PasswordAuthentication("testUser", "testPassword".toCharArray());
// It's not possible to mock static Authenticator methods. So we mock a delegate
private final class DelegatedAuthenticator extends Authenticator {
private final static class DelegatedAuthenticator extends Authenticator {
private final AuthenticatorDelegate authenticatorDelegate;
private DelegatedAuthenticator(final AuthenticatorDelegate authenticatorDelegate) {
@ -94,11 +94,11 @@ public class TestSystemDefaultCredentialsProvider {
final URL httpRequestUrl = new URL(TARGET_SCHEME1, TARGET_HOST1, TARGET_PORT1, "/");
final AuthScope authScope = new AuthScope(PROXY_PROTOCOL1, PROXY_HOST1, PROXY_PORT1, PROMPT1, StandardAuthScheme.BASIC);
final HttpCoreContext coreContext = new HttpCoreContext();
coreContext.setAttribute(HttpCoreContext.HTTP_REQUEST, new HttpGet(httpRequestUrl.toURI()));
final HttpClientContext context = new HttpClientContext();
context.setRequest(new HttpGet(httpRequestUrl.toURI()));
final Credentials receivedCredentials =
new SystemDefaultCredentialsProvider().getCredentials(authScope, coreContext);
new SystemDefaultCredentialsProvider().getCredentials(authScope, context);
Mockito.verify(authenticatorDelegate).getPasswordAuthentication(
PROXY_HOST1, null, PROXY_PORT1, PROXY_PROTOCOL1,

View File

@ -44,12 +44,11 @@ import org.apache.hc.client5.http.UnsupportedSchemeException;
import org.apache.hc.client5.http.config.TlsConfig;
import org.apache.hc.client5.http.io.DetachedSocketFactory;
import org.apache.hc.client5.http.io.ManagedHttpClientConnection;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.ssl.TlsSocketStrategy;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.io.SocketConfig;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.util.TimeValue;
import org.apache.hc.core5.util.Timeout;
@ -84,7 +83,7 @@ public class TestHttpClientConnectionOperator {
@Test
public void testConnect() throws Exception {
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final HttpHost host = new HttpHost("somehost");
final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 0});
final InetAddress ip1 = InetAddress.getByAddress(new byte[] {127, 0, 0, 1});
@ -117,7 +116,7 @@ public class TestHttpClientConnectionOperator {
@Test
public void testConnectWithTLSUpgrade() throws Exception {
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final HttpHost host = new HttpHost("https", "somehost");
final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 0});
final InetAddress ip1 = InetAddress.getByAddress(new byte[] {127, 0, 0, 1});
@ -153,7 +152,7 @@ public class TestHttpClientConnectionOperator {
@Test
public void testConnectTimeout() throws Exception {
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final HttpHost host = new HttpHost("somehost");
final InetAddress ip1 = InetAddress.getByAddress(new byte[] {10, 0, 0, 1});
final InetAddress ip2 = InetAddress.getByAddress(new byte[] {10, 0, 0, 2});
@ -170,7 +169,7 @@ public class TestHttpClientConnectionOperator {
@Test
public void testConnectFailure() throws Exception {
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final HttpHost host = new HttpHost("somehost");
final InetAddress ip1 = InetAddress.getByAddress(new byte[] {10, 0, 0, 1});
final InetAddress ip2 = InetAddress.getByAddress(new byte[] {10, 0, 0, 2});
@ -187,7 +186,7 @@ public class TestHttpClientConnectionOperator {
@Test
public void testConnectFailover() throws Exception {
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final HttpHost host = new HttpHost("somehost");
final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 0});
final InetAddress ip1 = InetAddress.getByAddress(new byte[] {10, 0, 0, 1});
@ -214,7 +213,7 @@ public class TestHttpClientConnectionOperator {
@Test
public void testConnectExplicitAddress() throws Exception {
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 0});
final InetAddress ip = InetAddress.getByAddress(new byte[] {127, 0, 0, 23});
final HttpHost host = new HttpHost(ip);
@ -236,7 +235,7 @@ public class TestHttpClientConnectionOperator {
@Test
public void testUpgrade() throws Exception {
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final HttpHost host = new HttpHost("https", "somehost", -1);
Mockito.when(conn.isOpen()).thenReturn(true);
@ -258,7 +257,7 @@ public class TestHttpClientConnectionOperator {
@Test
public void testUpgradeUpsupportedScheme() throws Exception {
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final HttpHost host = new HttpHost("httpsssss", "somehost", -1);
Mockito.when(conn.isOpen()).thenReturn(true);
@ -270,7 +269,7 @@ public class TestHttpClientConnectionOperator {
@Test
public void testUpgradeNonLayeringScheme() throws Exception {
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final HttpHost host = new HttpHost("http", "somehost", -1);
Mockito.when(conn.isOpen()).thenReturn(true);

View File

@ -32,7 +32,6 @@ import org.apache.hc.client5.http.SchemePortResolver;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@ -60,7 +59,7 @@ public class TestDefaultProxyRoutePlanner {
public void testDefaultProxyDirect() throws Exception {
final HttpHost target = new HttpHost("http", "somehost", 80);
final HttpContext context = new BasicHttpContext();
final HttpContext context = new HttpClientContext();
final HttpRoute route = routePlanner.determineRoute(target, context);
Assertions.assertEquals(target, route.getTargetHost());

View File

@ -35,7 +35,6 @@ import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.net.URIAuthority;
import org.junit.jupiter.api.Assertions;
@ -61,7 +60,7 @@ public class TestDefaultRoutePlanner {
public void testDirect() throws Exception {
final HttpHost target = new HttpHost("http", "somehost", 80);
final HttpContext context = new BasicHttpContext();
final HttpContext context = new HttpClientContext();
final HttpRoute route = routePlanner.determineRoute(target, context);
Assertions.assertEquals(target, route.getTargetHost());
@ -75,7 +74,7 @@ public class TestDefaultRoutePlanner {
final HttpHost target = new HttpHost("https", "somehost", -1);
Mockito.when(schemePortResolver.resolve(target)).thenReturn(443);
final HttpContext context = new BasicHttpContext();
final HttpContext context = new HttpClientContext();
final HttpRoute route = routePlanner.determineRoute(target, context);
Assertions.assertEquals(new HttpHost("https", "somehost", 443), route.getTargetHost());
@ -102,7 +101,7 @@ public class TestDefaultRoutePlanner {
@Test
public void testNullTarget() throws Exception {
final HttpContext context = new BasicHttpContext();
final HttpContext context = new HttpClientContext();
Assertions.assertThrows(ProtocolException.class, () ->
routePlanner.determineRoute(null, context));
}
@ -113,7 +112,7 @@ public class TestDefaultRoutePlanner {
final URIAuthority virtualHost = new URIAuthority("someotherhost", 443);
final HttpRequest request = new BasicHttpRequest("https", "GET", virtualHost, "/");
final HttpContext context = new BasicHttpContext();
final HttpContext context = new HttpClientContext();
final HttpRoute route = routePlanner.determineRoute(target, request, context);
Assertions.assertEquals(target, route.getTargetHost());
@ -129,7 +128,7 @@ public class TestDefaultRoutePlanner {
final URIAuthority virtualHost = new URIAuthority("someotherhost", 80);
final HttpRequest request = new BasicHttpRequest("http", "GET", virtualHost, "/");
final HttpContext context = new BasicHttpContext();
final HttpContext context = new HttpClientContext();
final HttpRoute route = routePlanner.determineRoute(target, request, context);
Assertions.assertEquals(target, route.getTargetHost());

View File

@ -37,9 +37,8 @@ import java.util.List;
import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.SchemePortResolver;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -67,7 +66,7 @@ public class TestSystemDefaultRoutePlanner {
public void testDirect() throws Exception {
final HttpHost target = new HttpHost("http", "somehost", 80);
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final HttpRoute route = routePlanner.determineRoute(target, context);
Assertions.assertEquals(target, route.getTargetHost());
@ -81,7 +80,7 @@ public class TestSystemDefaultRoutePlanner {
final HttpHost target = new HttpHost("https", "somehost", -1);
Mockito.when(schemePortResolver.resolve(target)).thenReturn(443);
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final HttpRoute route = routePlanner.determineRoute(target, context);
Assertions.assertEquals(new HttpHost("https", "somehost", 443), route.getTargetHost());
@ -106,7 +105,7 @@ public class TestSystemDefaultRoutePlanner {
final HttpHost target = new HttpHost("http", "somehost", 80);
final HttpContext context = new BasicHttpContext();
final HttpClientContext context = new HttpClientContext();
final HttpRoute route = routePlanner.determineRoute(target, context);
Assertions.assertEquals(target, route.getTargetHost());

View File

@ -49,7 +49,6 @@ import org.apache.hc.core5.http.HttpRequestInterceptor;
import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -189,7 +188,7 @@ public class TestRequestAddCookies {
final HttpRequest request = new BasicHttpRequest("GET", "/");
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpCoreContext.CONNECTION_ENDPOINT, null);
context.setEndpointDetails(null);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);

View File

@ -34,7 +34,6 @@ import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpRequestInterceptor;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -43,7 +42,7 @@ public class TestRequestDefaultHeaders {
@Test
public void testRequestParameterCheck() throws Exception {
final HttpContext context = new BasicHttpContext();
final HttpContext context = new HttpClientContext();
final HttpRequestInterceptor interceptor = RequestDefaultHeaders.INSTANCE;
Assertions.assertThrows(NullPointerException.class, () ->
interceptor.process(null, null, context));
@ -54,7 +53,7 @@ public class TestRequestDefaultHeaders {
final HttpRequest request = new BasicHttpRequest("CONNECT", "www.somedomain.com");
final List<Header> defheaders = new ArrayList<>();
defheaders.add(new BasicHeader("custom", "stuff"));
final HttpContext context = new BasicHttpContext();
final HttpContext context = new HttpClientContext();
final HttpRequestInterceptor interceptor = new RequestDefaultHeaders(defheaders);
interceptor.process(request, null, context);
@ -68,7 +67,7 @@ public class TestRequestDefaultHeaders {
request.addHeader("custom", "stuff");
final List<Header> defheaders = new ArrayList<>();
defheaders.add(new BasicHeader("custom", "other stuff"));
final HttpContext context = new BasicHttpContext();
final HttpContext context = new HttpClientContext();
final HttpRequestInterceptor interceptor = new RequestDefaultHeaders(defheaders);
interceptor.process(request, null, context);

View File

@ -37,8 +37,6 @@ import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@ -62,7 +60,7 @@ public class TestRequestExpectContinue {
@Test
public void testRequestExpectContinueNotGenerated() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final HttpClientContext context = new HttpClientContext();
final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(false).build();
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/");
@ -77,7 +75,7 @@ public class TestRequestExpectContinue {
@Test
public void testRequestExpectContinueHTTP10() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final HttpClientContext context = new HttpClientContext();
final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/");
@ -93,7 +91,7 @@ public class TestRequestExpectContinue {
@Test
public void testRequestExpectContinueZeroContent() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final HttpClientContext context = new HttpClientContext();
final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/");
@ -114,7 +112,7 @@ public class TestRequestExpectContinue {
@Test
public void testRequestExpectContinueIgnoreNonenclosingRequests() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final HttpClientContext context = new HttpClientContext();
final ClassicHttpRequest request = new BasicClassicHttpRequest("POST", "/");
final RequestExpectContinue interceptor = new RequestExpectContinue();
interceptor.process(request, null, context);

View File

@ -36,7 +36,6 @@ import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@ -104,7 +103,7 @@ class TestRequestUpgrade {
@Test
void testDoUpgradeIfAlreadyTLS() throws Exception {
context.setAttribute(HttpCoreContext.SSL_SESSION, Mockito.mock(SSLSession.class));
context.setSSLSession(Mockito.mock(SSLSession.class));
final HttpRequest get = new BasicHttpRequest("GET", "/");
interceptor.process(get, null, context);
Assertions.assertFalse(get.containsHeader(HttpHeaders.UPGRADE));

View File

@ -40,7 +40,6 @@ import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.impl.BasicEntityDetails;
import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -54,7 +53,7 @@ class TestRequestValidateTrace {
@BeforeEach
void setUp() {
interceptor = new RequestValidateTrace();
context = new BasicHttpContext();
context = new HttpClientContext();
}
@Test

View File

@ -62,7 +62,7 @@
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<httpcore.version>5.3-alpha1</httpcore.version>
<httpcore.version>5.3-alpha2</httpcore.version>
<log4j.version>2.22.0</log4j.version>
<brotli.version>0.1.2</brotli.version>
<conscrypt.version>2.5.2</conscrypt.version>