Skip to content

Commit

Permalink
Revert "proxy httpclient does not release connection pool when fronte…
Browse files Browse the repository at this point in the history
…nd close…" (#97)

This reverts commit 32381a3.
  • Loading branch information
tsegismont authored Sep 3, 2024
1 parent 9264b6d commit 859a564
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
11 changes: 0 additions & 11 deletions src/main/java/io/vertx/httpproxy/impl/ProxiedRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import io.vertx.core.http.*;
import io.vertx.core.internal.ContextInternal;
import io.vertx.core.internal.http.HttpServerRequestInternal;
import io.vertx.core.internal.logging.Logger;
import io.vertx.core.internal.logging.LoggerFactory;
import io.vertx.core.net.HostAndPort;
import io.vertx.core.streams.Pipe;
import io.vertx.httpproxy.Body;
Expand All @@ -27,7 +25,6 @@
import java.util.Objects;

public class ProxiedRequest implements ProxyRequest {
private final static Logger log = LoggerFactory.getLogger(ProxiedRequest.class);

private static final CharSequence X_FORWARDED_HOST = HttpHeaders.createOptimized("x-forwarded-host");

Expand Down Expand Up @@ -150,14 +147,6 @@ public ProxyResponse response() {
}

void sendRequest(Handler<AsyncResult<ProxyResponse>> responseHandler) {
proxiedRequest.connection().closeHandler(unused -> {
if (log.isTraceEnabled()) {
log.trace("Frontend connection closed,uri: " + proxiedRequest.uri());
}

request.reset();
proxiedRequest.response().reset();
});

request.response().<ProxyResponse>map(r -> {
r.pause(); // Pause it
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/io/vertx/tests/ProxyClientKeepAliveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public void testFrontendCloseResponse(TestContext ctx) {

@Test
public void testFrontendCloseChunkedResponse(TestContext ctx) {
testFrontendCloseResponse(ctx, true);
testBackendCloseResponse(ctx, true);
}

private void testFrontendCloseResponse(TestContext ctx, boolean chunked) {
Expand All @@ -279,11 +279,13 @@ private void testFrontendCloseResponse(TestContext ctx, boolean chunked) {
resp.putHeader("content-length", "10000");
}
resp.write("part");
resp.closeHandler(unused -> async.complete());
resp.exceptionHandler(err -> {
async.complete();
});
});
startProxy(backend);
client = vertx.createHttpClient();
client.request(GET, 8080, "localhost", "/").onComplete(ctx.asyncAssertSuccess(req -> {
client.request(GET, 8081, "localhost", "/").onComplete(ctx.asyncAssertSuccess(req -> {
req.send().onComplete(ctx.asyncAssertSuccess(resp -> {
resp.handler(buff -> {
resp.request().connection().close();
Expand Down

0 comments on commit 859a564

Please sign in to comment.