🚧 Fixed bug
This commit is contained in:
parent
edde990ed1
commit
4342956d06
@ -65,7 +65,8 @@ public class ProxyResource
|
||||
LOG.info("Matched route with target '{}'", route.target());
|
||||
try
|
||||
{
|
||||
HttpResponse<byte[]> response = forward(context.request().headers(), context.request().method(), context.body().buffer().getBytes(), route.strategy(), extractSession(context.request().cookies()), route.target(), concat(dropRoute(route.segments(), requestSegments)));
|
||||
byte[] body = extractBody(context);
|
||||
HttpResponse<byte[]> response = forward(context.request().headers(), context.request().method(), body, route.strategy(), extractSession(context.request().cookies()), route.target(), concat(dropRoute(route.segments(), requestSegments)));
|
||||
ResponseHandler.success(context, response);
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -81,9 +82,26 @@ public class ProxyResource
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] extractBody(RoutingContext context)
|
||||
{
|
||||
if (context.body().buffer() != null)
|
||||
{
|
||||
return context.body().buffer().getBytes();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HttpResponse<byte[]> forward(MultiMap headers, HttpMethod method, byte[] body, String strategy, String auth, String forwardRoot, String forwardPath) throws IOException, InterruptedException
|
||||
{
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder().method(method.name(), HttpRequest.BodyPublishers.ofByteArray(body)).uri(URI.create(forwardRoot + "/" + forwardPath));
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder().uri(URI.create(forwardRoot + "/" + forwardPath));
|
||||
if (body != null)
|
||||
{
|
||||
builder.method(method.name(), HttpRequest.BodyPublishers.ofByteArray(body));
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.method(method.name(), HttpRequest.BodyPublishers.noBody());
|
||||
}
|
||||
for (Map.Entry<String, String> entry : headers.entries())
|
||||
{
|
||||
try
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user