Skip to content

Commit

Permalink
HTTP client idle timeout should reset the stream with CANCEL (8) the …
Browse files Browse the repository at this point in the history
…HTTP/2 stream instead of resetting with a NO_ERROR (0) code.

Expand the timeout tests to HTTP/2
  • Loading branch information
vietj committed Nov 14, 2023
1 parent dd5df0d commit f17dcbc
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http2.*;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.handler.timeout.TimeoutException;
import io.vertx.core.*;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.*;
Expand Down Expand Up @@ -661,7 +662,14 @@ public void doSetWriteQueueMaxSize(int size) {

@Override
public void reset(Throwable cause) {
long code = cause instanceof StreamResetException ? ((StreamResetException)cause).getCode() : 0;
long code;
if (cause instanceof StreamResetException) {
code = ((StreamResetException)cause).getCode();
} else if (cause instanceof java.util.concurrent.TimeoutException) {
code = 0x08L; // CANCEL
} else {
code = 0L;
}
conn.context.emit(code, this::writeReset);
}

Expand Down
14 changes: 14 additions & 0 deletions src/test/java/io/vertx/core/http/Http1xClientTimeoutTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/
package io.vertx.core.http;

public class Http1xClientTimeoutTest extends HttpClientTimeoutTest {
}
24 changes: 24 additions & 0 deletions src/test/java/io/vertx/core/http/Http2ClientTimeoutTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2011-2023 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/
package io.vertx.core.http;

public class Http2ClientTimeoutTest extends HttpClientTimeoutTest {

@Override
protected HttpServerOptions createBaseServerOptions() {
return Http2ServerTest.createHttp2ServerOptions(HttpTestBase.DEFAULT_HTTPS_PORT, HttpTestBase.DEFAULT_HTTPS_HOST);
}

@Override
protected HttpClientOptions createBaseClientOptions() {
return Http2ServerTest.createHttp2ClientOptions();
}
}
Loading

0 comments on commit f17dcbc

Please sign in to comment.