Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-10-18 Thread via GitHub


ok2c commented on code in PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#discussion_r2433217241


##
httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/EarlyHintsAsyncExec.java:
##
@@ -0,0 +1,108 @@
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package org.apache.hc.client5.http.impl.async;
+
+import org.apache.hc.client5.http.EarlyHintsListener;
+import org.apache.hc.client5.http.async.AsyncExecCallback;
+import org.apache.hc.client5.http.async.AsyncExecChain;
+import org.apache.hc.client5.http.async.AsyncExecChainHandler;
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.nio.AsyncEntityProducer;
+import org.apache.hc.core5.http.protocol.HttpContext;
+
+/**
+ * Execution chain handler that delivers {@code 103 Early Hints} 
(RFC 8297)

Review Comment:
   @arturobernalg I would prefer if we made no references to specific RFCs in 
our source code. If in the future the RFC gets superseded by another 
specification we would not need to chase all the references to that RFC in our 
source code.
   
   Commit message would be the right place to mention it.



##
httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/EarlyHintsAsyncExec.java:
##
@@ -0,0 +1,108 @@
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package org.apache.hc.client5.http.impl.async;
+
+import org.apache.hc.client5.http.EarlyHintsListener;
+import org.apache.hc.client5.http.async.AsyncExecCallback;
+import org.apache.hc.client5.http.async.AsyncExecChain;
+import org.apache.hc.client5.http.async.AsyncExecChainHandler;
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.nio.AsyncEntityProducer;
+import org.apache.hc.core5.http.protocol.HttpContext;
+
+/**
+ * Execution chain handler that delivers {@code 103 Early Hints} 
(RFC 8297)
+ * informational responses to a user-provided {@link 
org.apache.hc.client5.http.EarlyHintsListener}
+ * without affecting the final (non-1xx) response processing.
+ *
+ * This handler wraps the downstream {@link 
org.apache.hc.client5.http.async.AsyncExecCallback}
+ * and forwards any informational response with code
+ * {@link org.apache.hc.core5.http.HttpStatus#SC_EARLY_HINTS 103} to the 
listener.
+ * All other responses (inc

Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-10-18 Thread via GitHub


arturobernalg commented on code in PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#discussion_r2434743844


##
httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncEarlyHintsEndToEndDemo.java:
##
@@ -0,0 +1,174 @@
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package org.apache.hc.client5.http.examples;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.hc.client5.http.EarlyHintsListener;
+import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
+import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
+import org.apache.hc.client5.http.async.methods.SimpleRequestBuilder;
+import org.apache.hc.client5.http.config.TlsConfig;
+import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
+import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
+import 
org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.URIScheme;
+import org.apache.hc.core5.http.impl.BasicEntityDetails;
+import org.apache.hc.core5.http.impl.bootstrap.AsyncServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpAsyncServer;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
+import org.apache.hc.core5.http.nio.CapacityChannel;
+import org.apache.hc.core5.http.nio.DataStreamChannel;
+import org.apache.hc.core5.http.nio.ResponseChannel;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.io.CloseMode;
+import org.apache.hc.core5.reactor.ListenerEndpoint;
+
+/**
+ * Minimal end-to-end demo for {@code 103 Early Hints} using the async client.
+ *
+ * This example starts a tiny local async HTTP server that:
+ * 
+ *   sends a {@code 103} informational response with two {@code Link} 
headers, then
+ *   completes the exchange with a final {@code 200 OK} and a short 
body.
+ * 
+ * The async client registers an Early Hints listener, prints any received 
{@code 103}
+ * headers, and then prints the final status and body.
+ *
+ * Use this sample to see how to wire {@code setEarlyHintsListener(...)} 
and verify that
+ * Early Hints do not interfere with normal response processing.
+ */
+
+public class AsyncEarlyHintsEndToEndDemo {

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-10-17 Thread via GitHub


ok2c commented on code in PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#discussion_r2433791372


##
httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/EarlyHintsAsyncExecTest.java:
##
@@ -0,0 +1,202 @@
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package org.apache.hc.client5.http.impl.async;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.hc.client5.http.EarlyHintsListener;
+import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
+import org.apache.hc.client5.http.async.methods.SimpleRequestBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.URIScheme;
+import org.apache.hc.core5.http.impl.BasicEntityDetails;
+import org.apache.hc.core5.http.impl.bootstrap.AsyncServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpAsyncServer;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
+import org.apache.hc.core5.http.nio.CapacityChannel;
+import org.apache.hc.core5.http.nio.DataStreamChannel;
+import org.apache.hc.core5.http.nio.ResponseChannel;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.io.CloseMode;
+import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.reactor.ListenerEndpoint;
+import org.apache.hc.core5.util.Timeout;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+
+class EarlyHintsAsyncExecTest {
+
+private HttpAsyncServer server;
+
+@AfterEach
+void tearDown() {
+if (server != null) {
+server.close(CloseMode.GRACEFUL);
+}
+}
+
+@Test
[email protected](10)

Review Comment:
   @arturobernalg Understood.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-10-17 Thread via GitHub


ok2c commented on PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#issuecomment-3393591838

   @arturobernalg I agree with @rschmitt I would not add this feature to the 
classic transport at all. The implementation for the classic i/o looks clumsy 
and it is not worth it. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-10-17 Thread via GitHub


ok2c commented on code in PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#discussion_r2433797556


##
httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncEarlyHintsEndToEndDemo.java:
##
@@ -0,0 +1,174 @@
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package org.apache.hc.client5.http.examples;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.hc.client5.http.EarlyHintsListener;
+import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
+import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
+import org.apache.hc.client5.http.async.methods.SimpleRequestBuilder;
+import org.apache.hc.client5.http.config.TlsConfig;
+import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
+import org.apache.hc.client5.http.impl.async.HttpAsyncClients;
+import 
org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.URIScheme;
+import org.apache.hc.core5.http.impl.BasicEntityDetails;
+import org.apache.hc.core5.http.impl.bootstrap.AsyncServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpAsyncServer;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
+import org.apache.hc.core5.http.nio.CapacityChannel;
+import org.apache.hc.core5.http.nio.DataStreamChannel;
+import org.apache.hc.core5.http.nio.ResponseChannel;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.io.CloseMode;
+import org.apache.hc.core5.reactor.ListenerEndpoint;
+
+/**
+ * Minimal end-to-end demo for {@code 103 Early Hints} using the async client.
+ *
+ * This example starts a tiny local async HTTP server that:
+ * 
+ *   sends a {@code 103} informational response with two {@code Link} 
headers, then
+ *   completes the exchange with a final {@code 200 OK} and a short 
body.
+ * 
+ * The async client registers an Early Hints listener, prints any received 
{@code 103}
+ * headers, and then prints the final status and body.
+ *
+ * Use this sample to see how to wire {@code setEarlyHintsListener(...)} 
and verify that
+ * Early Hints do not interfere with normal response processing.
+ */
+
+public class AsyncEarlyHintsEndToEndDemo {

Review Comment:
   @arturobernalg Can we name it `AsyncClientEarlyHintsEndToEnd` or 
`AsyncClientEarlyHintsEndToEndExample` for consistency with existing examples?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-10-17 Thread via GitHub


arturobernalg commented on code in PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#discussion_r2433371304


##
httpclient5/src/test/java/org/apache/hc/client5/http/impl/async/EarlyHintsAsyncExecTest.java:
##
@@ -0,0 +1,202 @@
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package org.apache.hc.client5.http.impl.async;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.apache.hc.client5.http.EarlyHintsListener;
+import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
+import org.apache.hc.client5.http.async.methods.SimpleRequestBuilder;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.URIScheme;
+import org.apache.hc.core5.http.impl.BasicEntityDetails;
+import org.apache.hc.core5.http.impl.bootstrap.AsyncServerBootstrap;
+import org.apache.hc.core5.http.impl.bootstrap.HttpAsyncServer;
+import org.apache.hc.core5.http.message.BasicHttpResponse;
+import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
+import org.apache.hc.core5.http.nio.CapacityChannel;
+import org.apache.hc.core5.http.nio.DataStreamChannel;
+import org.apache.hc.core5.http.nio.ResponseChannel;
+import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.io.CloseMode;
+import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.reactor.ListenerEndpoint;
+import org.apache.hc.core5.util.Timeout;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+
+class EarlyHintsAsyncExecTest {
+
+private HttpAsyncServer server;
+
+@AfterEach
+void tearDown() {
+if (server != null) {
+server.close(CloseMode.GRACEFUL);
+}
+}
+
+@Test
[email protected](10)

Review Comment:
   @ok2c The only reason I qualified the annotation is the name clash with 
`org.apache.hc.core5.util.Timeout` used in `setSoTimeout(Timeout.ofSeconds(5))`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-10-15 Thread via GitHub


ok2c commented on code in PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#discussion_r2433793449


##
httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/EarlyHintsAsyncExec.java:
##
@@ -0,0 +1,108 @@
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * .
+ *
+ */
+package org.apache.hc.client5.http.impl.async;
+
+import org.apache.hc.client5.http.EarlyHintsListener;
+import org.apache.hc.client5.http.async.AsyncExecCallback;
+import org.apache.hc.client5.http.async.AsyncExecChain;
+import org.apache.hc.client5.http.async.AsyncExecChainHandler;
+import org.apache.hc.core5.http.EntityDetails;
+import org.apache.hc.core5.http.HttpException;
+import org.apache.hc.core5.http.HttpRequest;
+import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.nio.AsyncEntityProducer;
+import org.apache.hc.core5.http.protocol.HttpContext;
+
+/**
+ * Execution chain handler that delivers {@code 103 Early Hints} 
(RFC 8297)
+ * informational responses to a user-provided {@link 
org.apache.hc.client5.http.EarlyHintsListener}
+ * without affecting the final (non-1xx) response processing.
+ *
+ * This handler wraps the downstream {@link 
org.apache.hc.client5.http.async.AsyncExecCallback}
+ * and forwards any informational response with code
+ * {@link org.apache.hc.core5.http.HttpStatus#SC_EARLY_HINTS 103} to the 
listener.
+ * All other responses (including the final response) are delegated 
unchanged.
+ *
+ *
+ * For security and interoperability, applications typically act only on
+ * headers considered safe in Early Hints (for example, {@code Link} with
+ * {@code rel=preload} or {@code rel=preconnect}).
+ *
+ * @see org.apache.hc.client5.http.EarlyHintsListener
+ * @see org.apache.hc.core5.http.HttpStatus#SC_EARLY_HINTS
+ * @see 
org.apache.hc.core5.http.nio.ResponseChannel#sendInformation(HttpResponse, 
HttpContext)
+ * @since 5.6
+ */
+public final class EarlyHintsAsyncExec implements AsyncExecChainHandler {
+private final EarlyHintsListener listener;
+
+public EarlyHintsAsyncExec(final EarlyHintsListener listener) {
+this.listener = listener;
+}
+
+@Override
+public void execute(final HttpRequest request,
+final AsyncEntityProducer entityProducer,
+final AsyncExecChain.Scope scope,
+final AsyncExecChain chain,
+final AsyncExecCallback callback) throws 
HttpException, java.io.IOException {

Review Comment:
   @arturobernalg This one still uses full class name. Should it?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-10-12 Thread via GitHub


arturobernalg commented on PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#issuecomment-3393599887

   > @arturobernalg I agree with @rschmitt I would not add this feature to the 
classic transport at all. The implementation for the classic i/o looks clumsy 
and it is not worth it.
   
   @ok2c  I’ll scope Early Hints to the async client only and drop the classic 
wiring.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-08-16 Thread via GitHub


rschmitt commented on PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#issuecomment-3193940899

   > The page 
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103 suggests 
`103` should only be for HTTP/2 or later.
   
   And rightly so. HTTP/1.1's framing is inherently unreliable and they're 
still finding [desync attacks](https://portswigger.net/research/http1-must-die) 
in the wild. Additionally, this type of scheme works best with async IO, so 
that the `103` response can be handled as soon as it comes in, and only HTTP/2 
is reliably implemented with async IO (since it's a multiplexed protocol). I 
also find it strange that this RFC provides no way for the client to signal its 
support for this feature, analogous to `Expect: 100-continue`. Who the hell 
would just turn this feature on in production for all clients?
   
   I agree that the client should at least _tolerate_ `103` responses, but I 
don't have a strong opinion about how to expose them. The dedicated callback in 
the PR seems reasonable.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-08-16 Thread via GitHub


garydgregory commented on PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#issuecomment-3193837235

   Thank you for the details @arturobernalg 👌


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-08-16 Thread via GitHub


arturobernalg commented on PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#issuecomment-3193743252

   > > > Hi all,
   > 
   > > > The page 
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103 suggests 
`103` should only be for HTTP/2 or later. Should this PR only apply to HTTP/2?
   > 
   > > 
   > 
   > > For what I understand MDN’s note is a deployment recommendation, not a 
protocol limit. RFC 8297 does not restrict 103 to HTTP/2+
   > 
   > 
   > 
   > Check. I wonder if the fact that this is an RFC marked "Experimental" 
should be of concern, or at least mentioned in the Javadoc.
   > 
   > 
   
   The RFC text is immutable, so the body still says “Experimental” (that’s the 
original 2017 publication). However, the IESG later changed the status to 
Proposed Standard; that action is recorded separately and Datatracker now shows 
the badge accordingly. Official status-change doc (Feb 5, 2025) is here.  
   For reference, the original RFC body that still reads “Experimental” is here 
(unchanged by design). 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-08-16 Thread via GitHub


garydgregory commented on PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#issuecomment-3193647908

   > > Hi all,
   > > The page 
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103 suggests 
`103` should only be for HTTP/2 or later. Should this PR only apply to HTTP/2?
   > 
   > For what I understand MDN’s note is a deployment recommendation, not a 
protocol limit. RFC 8297 does not restrict 103 to HTTP/2+
   
   Check. I wonder if the fact that this is an RFC marked "Experimental" should 
be of concern, or at least mentioned in the Javadoc.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-08-16 Thread via GitHub


arturobernalg commented on PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#issuecomment-3193646216

   > Hi all,
   > 
   > 
   > 
   > The page 
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103 suggests 
`103` should only be for HTTP/2 or later. Should this PR only apply to HTTP/2?
   
   For what I understand MDN’s note is a deployment recommendation, not a 
protocol limit. RFC 8297 does not restrict 103 to HTTP/2+


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Add RFC 8297 (103 Early Hints) support to HttpClient5 (classic & async) [httpcomponents-client]

2025-08-16 Thread via GitHub


garydgregory commented on PR #707:
URL: 
https://github.com/apache/httpcomponents-client/pull/707#issuecomment-3193622421

   Hi all,
   
   The page 
https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/103 suggests 
`103` should only be for HTTP/2 or laster. Should this PR only apply to HTTP/2?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]