Please open a github issue if the issue can be easily replicated
On 03/05/13 00:29, Max Calderoni wrote:
Hi,
have the same question about using Pump in an http proxy as described in
this thread.
Was anybody able to do this?
I am attaching some code that does not work as i wished.
To run it (check the code first as there is one hardcoded file path - you
need to give it a file to upload), you do:
vertx run UploadServer.java
vertx run ProxyServer.java
vertx run UploadClient.java -instances 2
It will upload the file, but only one, not two, while i have two verticles,
so, should be two files.
From other posts i read, sounds like Pump cannot be used this way, but i
wish someone confirmed that.
Max
--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/9x2p7AGx7kM/unsubscribe?hl=en-GB.
To unsubscribe from this group and all of its topics, send an email to vertx+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
To unsubscribe from this group and all of its topics, send an email to vertx+un...@googlegroups.com.
--
Max Calderoni
Try adding .start()Pump.createPump(clientResponse, request.response).start();
--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/9x2p7AGx7kM/unsubscribe?hl=en-GB.
To unsubscribe from this group and all of its topics, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
/**
* Send a request received by the proxy, forward it to the Nexus server, and send back the results
* @param ctx The {@link RoutingContext} of the request
*/
private void sendProxyRequest(RoutingContext ctx) {
String urlWithQueryParams = ctx.request().uri().split("/", 3)[4];
String uri = "http://"
+ context.config().getString("targetHost")
+ ":"
+ context.config().getString("targetPort")
+ "/" + urlWithQueryParams;
HttpClient client = vertx.createHttpClient(new HttpClientOptions());
final HttpClientRequest req = client.request(ctx.request().method(), uri);
req.headers().clear().addAll(ctx.request().headers());
req.endHandler(end -> {
ctx.response().end();
});
req.setChunked(true);
req.handler(pResponse -> {
ctx.response().headers().clear().addAll(pResponse.headers());
ctx.response().setStatusCode(pResponse.statusCode());
ctx.response().setStatusMessage(pResponse.statusMessage());
ctx.response().setChunked(true);
Pump targetToProxy = Pump.pump(pResponse, ctx.response());
});
Pump proxyToTarget = Pump.pump(ctx.request(), req);
proxyToTarget.start();
}
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.