Skip to content

Commit f17dcbc

Browse files
committed
HTTP client idle timeout should reset the stream with CANCEL (8) the HTTP/2 stream instead of resetting with a NO_ERROR (0) code.
Expand the timeout tests to HTTP/2
1 parent dd5df0d commit f17dcbc

File tree

4 files changed

+179
-153
lines changed

4 files changed

+179
-153
lines changed

src/main/java/io/vertx/core/http/impl/Http2ClientConnection.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.netty.handler.codec.http.HttpResponseStatus;
1818
import io.netty.handler.codec.http2.*;
1919
import io.netty.handler.timeout.IdleStateEvent;
20+
import io.netty.handler.timeout.TimeoutException;
2021
import io.vertx.core.*;
2122
import io.vertx.core.buffer.Buffer;
2223
import io.vertx.core.http.*;
@@ -661,7 +662,14 @@ public void doSetWriteQueueMaxSize(int size) {
661662

662663
@Override
663664
public void reset(Throwable cause) {
664-
long code = cause instanceof StreamResetException ? ((StreamResetException)cause).getCode() : 0;
665+
long code;
666+
if (cause instanceof StreamResetException) {
667+
code = ((StreamResetException)cause).getCode();
668+
} else if (cause instanceof java.util.concurrent.TimeoutException) {
669+
code = 0x08L; // CANCEL
670+
} else {
671+
code = 0L;
672+
}
665673
conn.context.emit(code, this::writeReset);
666674
}
667675

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7+
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
8+
*
9+
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
10+
*/
11+
package io.vertx.core.http;
12+
13+
public class Http1xClientTimeoutTest extends HttpClientTimeoutTest {
14+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
7+
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
8+
*
9+
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
10+
*/
11+
package io.vertx.core.http;
12+
13+
public class Http2ClientTimeoutTest extends HttpClientTimeoutTest {
14+
15+
@Override
16+
protected HttpServerOptions createBaseServerOptions() {
17+
return Http2ServerTest.createHttp2ServerOptions(HttpTestBase.DEFAULT_HTTPS_PORT, HttpTestBase.DEFAULT_HTTPS_HOST);
18+
}
19+
20+
@Override
21+
protected HttpClientOptions createBaseClientOptions() {
22+
return Http2ServerTest.createHttp2ClientOptions();
23+
}
24+
}

0 commit comments

Comments
 (0)