You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2022/09/11 16:56:13 UTC
[httpcomponents-client] branch 5.1.x updated: HTTPCLIENT-2232: last protocol interceptrs moved at the end of the H2 protocol processing pipeline
This is an automated email from the ASF dual-hosted git repository.
olegk pushed a commit to branch 5.1.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
The following commit(s) were added to refs/heads/5.1.x by this push:
new ce41bf26c HTTPCLIENT-2232: last protocol interceptrs moved at the end of the H2 protocol processing pipeline
ce41bf26c is described below
commit ce41bf26c4a51d8e20b4da0c820486bb6ffb2ef2
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Sun Sep 11 18:54:18 2022 +0200
HTTPCLIENT-2232: last protocol interceptrs moved at the end of the H2 protocol processing pipeline
---
.../http/impl/async/H2AsyncClientBuilder.java | 39 +++++++++++-----------
.../http/impl/async/HttpAsyncClientBuilder.java | 38 +++++++++++----------
2 files changed, 40 insertions(+), 37 deletions(-)
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/H2AsyncClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/H2AsyncClientBuilder.java
index 8a0f82afa..28435d4ec 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/H2AsyncClientBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/H2AsyncClientBuilder.java
@@ -44,8 +44,8 @@ import org.apache.hc.client5.http.HttpRequestRetryStrategy;
import org.apache.hc.client5.http.SchemePortResolver;
import org.apache.hc.client5.http.async.AsyncExecChainHandler;
import org.apache.hc.client5.http.auth.AuthSchemeFactory;
-import org.apache.hc.client5.http.auth.StandardAuthScheme;
import org.apache.hc.client5.http.auth.CredentialsProvider;
+import org.apache.hc.client5.http.auth.StandardAuthScheme;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.cookie.BasicCookieStore;
import org.apache.hc.client5.http.cookie.CookieSpecFactory;
@@ -93,7 +93,6 @@ import org.apache.hc.core5.http.nio.command.ShutdownCommand;
import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
import org.apache.hc.core5.http.protocol.HttpContext;
-import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.http.protocol.HttpProcessorBuilder;
import org.apache.hc.core5.http.protocol.RequestTargetHost;
import org.apache.hc.core5.http.protocol.RequestUserAgent;
@@ -656,24 +655,9 @@ public class H2AsyncClientBuilder {
if (!cookieManagementDisabled) {
b.add(new ResponseProcessCookies());
}
- if (requestInterceptors != null) {
- for (final RequestInterceptorEntry entry: requestInterceptors) {
- if (entry.position == RequestInterceptorEntry.Position.LAST) {
- b.addLast(entry.interceptor);
- }
- }
- }
- if (responseInterceptors != null) {
- for (final ResponseInterceptorEntry entry: responseInterceptors) {
- if (entry.position == ResponseInterceptorEntry.Position.LAST) {
- b.addLast(entry.interceptor);
- }
- }
- }
- final HttpProcessor httpProcessor = b.build();
execChainDefinition.addFirst(
- new AsyncProtocolExec(httpProcessor, targetAuthStrategyCopy, proxyAuthStrategyCopy, schemePortResolver),
+ new AsyncProtocolExec(b.build(), targetAuthStrategyCopy, proxyAuthStrategyCopy, schemePortResolver),
ChainElement.PROTOCOL.name());
// Add request retry executor, if not disabled
@@ -707,9 +691,26 @@ public class H2AsyncClientBuilder {
ChainElement.REDIRECT.name());
}
+ final HttpProcessorBuilder b2 = HttpProcessorBuilder.create();
+ b2.addAll(new H2RequestContent(), new H2RequestTargetHost(), new H2RequestConnControl());
+ if (requestInterceptors != null) {
+ for (final RequestInterceptorEntry entry: requestInterceptors) {
+ if (entry.position == RequestInterceptorEntry.Position.LAST) {
+ b2.addLast(entry.interceptor);
+ }
+ }
+ }
+ if (responseInterceptors != null) {
+ for (final ResponseInterceptorEntry entry: responseInterceptors) {
+ if (entry.position == ResponseInterceptorEntry.Position.LAST) {
+ b2.addLast(entry.interceptor);
+ }
+ }
+ }
+
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
final IOEventHandlerFactory ioEventHandlerFactory = new H2AsyncClientEventHandlerFactory(
- new DefaultHttpProcessor(new H2RequestContent(), new H2RequestTargetHost(), new H2RequestConnControl()),
+ b2.build(),
new HandlerFactory<AsyncPushConsumer>() {
@Override
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
index 6a8384916..a665f24ae 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
@@ -102,7 +102,6 @@ import org.apache.hc.core5.http.nio.HandlerFactory;
import org.apache.hc.core5.http.nio.command.ShutdownCommand;
import org.apache.hc.core5.http.protocol.DefaultHttpProcessor;
import org.apache.hc.core5.http.protocol.HttpContext;
-import org.apache.hc.core5.http.protocol.HttpProcessor;
import org.apache.hc.core5.http.protocol.HttpProcessorBuilder;
import org.apache.hc.core5.http.protocol.RequestTargetHost;
import org.apache.hc.core5.http.protocol.RequestUserAgent;
@@ -817,24 +816,9 @@ public class HttpAsyncClientBuilder {
if (!cookieManagementDisabled) {
b.add(new ResponseProcessCookies());
}
- if (requestInterceptors != null) {
- for (final RequestInterceptorEntry entry: requestInterceptors) {
- if (entry.position == RequestInterceptorEntry.Position.LAST) {
- b.addLast(entry.interceptor);
- }
- }
- }
- if (responseInterceptors != null) {
- for (final ResponseInterceptorEntry entry: responseInterceptors) {
- if (entry.position == ResponseInterceptorEntry.Position.LAST) {
- b.addLast(entry.interceptor);
- }
- }
- }
- final HttpProcessor httpProcessor = b.build();
execChainDefinition.addFirst(
- new AsyncProtocolExec(httpProcessor, targetAuthStrategyCopy, proxyAuthStrategyCopy, schemePortResolver),
+ new AsyncProtocolExec(b.build(), targetAuthStrategyCopy, proxyAuthStrategyCopy, schemePortResolver),
ChainElement.PROTOCOL.name());
// Add request retry executor, if not disabled
@@ -922,9 +906,27 @@ public class HttpAsyncClientBuilder {
reuseStrategyCopy = DefaultClientConnectionReuseStrategy.INSTANCE;
}
}
+
+ final HttpProcessorBuilder b2 = HttpProcessorBuilder.create();
+ b2.addAll(new H2RequestContent(), new H2RequestTargetHost(), new H2RequestConnControl());
+ if (requestInterceptors != null) {
+ for (final RequestInterceptorEntry entry: requestInterceptors) {
+ if (entry.position == RequestInterceptorEntry.Position.LAST) {
+ b2.addLast(entry.interceptor);
+ }
+ }
+ }
+ if (responseInterceptors != null) {
+ for (final ResponseInterceptorEntry entry: responseInterceptors) {
+ if (entry.position == ResponseInterceptorEntry.Position.LAST) {
+ b2.addLast(entry.interceptor);
+ }
+ }
+ }
+
final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();
final IOEventHandlerFactory ioEventHandlerFactory = new HttpAsyncClientEventHandlerFactory(
- new DefaultHttpProcessor(new H2RequestContent(), new H2RequestTargetHost(), new H2RequestConnControl()),
+ b2.build(),
new HandlerFactory<AsyncPushConsumer>() {
@Override