yhzdys created HTTPCLIENT-2425:
----------------------------------

             Summary: RequestConfig#responseTimeout is not enforced for HTTP/2 
streams
                 Key: HTTPCLIENT-2425
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2425
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpClient (async)
    Affects Versions: 5.6.2
         Environment: HttpClient Version: 5.6.2
Java Version: OpenJDK 17+
Protocol: HTTP/2 (h2)
            Reporter: yhzdys


h2. Description

{{*RequestConfig#responseTimeout*}} is not enforced when using 
{{CloseableHttpAsyncClient}} over HTTP/2. The configured timeout value is 
ignored, and the request completes only after receiving the full server 
response. This behavior does not occur under HTTP/1.1.
h2. Minimal Reproducible Example

 
{code:java}
import org.apache.hc.client5.http.async.methods.SimpleHttpRequest;
import org.apache.hc.client5.http.async.methods.SimpleHttpResponse;
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
import org.apache.hc.client5.http.impl.async.HttpAsyncClientBuilder;
import org.apache.hc.core5.util.Timeout;
import org.junit.jupiter.api.Test;
public class ResponseTimeoutTest {
    @Test
    public void testResponseTimeoutWithH2() throws Exception {
        CloseableHttpAsyncClient client = 
HttpAsyncClientBuilder.create().build();
        client.start();
        
        RequestConfig config = RequestConfig.custom()
                .setResponseTimeout(Timeout.ofSeconds(1L))
                .build();
                
        SimpleHttpRequest request = SimpleHttpRequest.create("GET", 
"https://httpbingo.org/delay/3";);
        request.setConfig(config);
        // Expected: Should throw timeout exception after ~1 second
        // Actual: Returns successfully after ~3 seconds
        SimpleHttpResponse response = client.execute(request, null).get();
        System.out.println(response);
    }
}
{code}
h2. Expected Behavior

The future should complete exceptionally with a timeout-related exception after 
approximately 1 second, as defined by {*}RequestConfig#responseTimeout{*}.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to