More consistent request interceptor naming; fixed inconsistent sequence of request interceptors in the classic and async HttpClient builders

This commit is contained in:
Oleg Kalnichevski 2024-01-22 16:35:27 +01:00
parent a1e8e9082e
commit 4f8f34fe5c
4 changed files with 17 additions and 18 deletions

View File

@ -76,6 +76,7 @@ import org.apache.hc.client5.http.protocol.RedirectStrategy;
import org.apache.hc.client5.http.protocol.RequestAddCookies;
import org.apache.hc.client5.http.protocol.RequestDefaultHeaders;
import org.apache.hc.client5.http.protocol.RequestExpectContinue;
import org.apache.hc.client5.http.protocol.RequestValidateTrace;
import org.apache.hc.client5.http.protocol.ResponseProcessCookies;
import org.apache.hc.client5.http.routing.HttpRoutePlanner;
import org.apache.hc.core5.annotation.Internal;
@ -837,11 +838,12 @@ public class HttpAsyncClientBuilder {
}
b.addAll(
new H2RequestTargetHost(),
new RequestValidateTrace(),
new RequestDefaultHeaders(defaultHeaders),
new RequestUserAgent(userAgentCopy),
new RequestExpectContinue(),
new H2RequestContent(),
new H2RequestConnControl());
new H2RequestConnControl(),
new RequestUserAgent(userAgentCopy),
new RequestExpectContinue());
if (!cookieManagementDisabled) {
b.add(RequestAddCookies.INSTANCE);
}

View File

@ -77,11 +77,10 @@ import org.apache.hc.client5.http.impl.routing.SystemDefaultRoutePlanner;
import org.apache.hc.client5.http.io.HttpClientConnectionManager;
import org.apache.hc.client5.http.protocol.RedirectStrategy;
import org.apache.hc.client5.http.protocol.RequestAddCookies;
import org.apache.hc.client5.http.protocol.RequestTraceInterceptor;
import org.apache.hc.client5.http.protocol.RequestClientConnControl;
import org.apache.hc.client5.http.protocol.RequestDefaultHeaders;
import org.apache.hc.client5.http.protocol.RequestExpectContinue;
import org.apache.hc.client5.http.protocol.RequestIfRange;
import org.apache.hc.client5.http.protocol.RequestValidateTrace;
import org.apache.hc.client5.http.protocol.ResponseProcessCookies;
import org.apache.hc.client5.http.routing.HttpRoutePlanner;
import org.apache.hc.core5.annotation.Internal;
@ -819,15 +818,13 @@ public class HttpClientBuilder {
}
}
b.addAll(
new RequestTargetHost(),
new RequestValidateTrace(),
new RequestDefaultHeaders(defaultHeaders),
new RequestContent(),
new RequestTargetHost(),
new RequestClientConnControl(),
new RequestUserAgent(userAgentCopy),
new RequestExpectContinue(),
new RequestTraceInterceptor(),
new RequestExpectContinue(),
new RequestIfRange());
new RequestExpectContinue());
if (!cookieManagementDisabled) {
b.add(RequestAddCookies.INSTANCE);
}

View File

@ -100,19 +100,19 @@ import org.slf4j.LoggerFactory;
* @see HttpHeaders#COOKIE
*/
@Contract(threading = ThreadingBehavior.STATELESS)
public class RequestTraceInterceptor implements HttpRequestInterceptor {
public class RequestValidateTrace implements HttpRequestInterceptor {
private static final Logger LOG = LoggerFactory.getLogger(RequestTraceInterceptor.class);
private static final Logger LOG = LoggerFactory.getLogger(RequestValidateTrace.class);
/**
* Singleton instance of {@link RequestTraceInterceptor}.
* Singleton instance of {@link RequestValidateTrace}.
*/
public static final HttpRequestInterceptor INSTANCE = new RequestTraceInterceptor();
public static final HttpRequestInterceptor INSTANCE = new RequestValidateTrace();
/**
* Default constructor.
*/
public RequestTraceInterceptor() {
public RequestValidateTrace() {
super();
}

View File

@ -45,15 +45,15 @@ import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class TestRequestTraceInterceptor {
class TestRequestValidateTrace {
private RequestTraceInterceptor interceptor;
private RequestValidateTrace interceptor;
private HttpRequest request;
private HttpContext context;
@BeforeEach
void setUp() {
interceptor = new RequestTraceInterceptor();
interceptor = new RequestValidateTrace();
context = new BasicHttpContext();
}