Skip to content

proxy fail with nothing when use BodyHandler before the router #26

Closed as not planned
@Linindoo

Description

@Linindoo

Questions

if i add a BodyHandler before proxyRouter ,it can not get anything but wait always
the origin server is :

Vertx vertx = Vertx.vertx();
        HttpServer backendServer = vertx.createHttpServer();

        Router backendRouter = Router.router(vertx);
        backendRouter.route(HttpMethod.GET, "/foo2").handler(rc -> {
            rc.response()
                    .putHeader("content-type", "text/html")
                    .end("<html><body><h1>I'm the target resource!</h1></body></html>");
        });
        backendServer.requestHandler(backendRouter).listen(7070);

the proxy server is :

Vertx vertx = Vertx.vertx();
        HttpServer proxyServer = vertx.createHttpServer();

        Router proxyRouter = Router.router(vertx);
        proxyRouter.route().handler(SessionHandler.create(LocalSessionStore.create(vertx)));
        proxyRouter.route().handler(BodyHandler.create());
        proxyRouter.route("/upload/*").handler(ResourceHandler.create("upload"));

        proxyServer.requestHandler(proxyRouter);
        HttpClient proxyClient = vertx.createHttpClient();
        proxyRouter.route(HttpMethod.GET, "/foo").handler(context->{
            ProxyRequest proxyRequest = ProxyRequest.reverseProxy(context.request());
            proxyRequest.setURI("/foo2");
            proxyClient.request(proxyRequest.getMethod(), 7070, "localhost", "foo2").compose(proxyRequest::send)
                    .onSuccess(x -> {
                        x.send();
                    })
                    .onFailure(err -> {
                        err.printStackTrace();
                        proxyRequest.release();
                    });
        });
        proxyServer.listen(8089);

if i remove the BodyHandler it can proxy correct

Version

vertx version :4.1.5
OS version: Win10
JVM version:1.8

Metadata

Metadata

Assignees

Labels

invalidThis doesn't seem right

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions