use of com.facebook.presto.proxy.ProxyResponseHandler.ProxyResponse in project presto by prestodb.
the class ProxyResource method performRequest.
private void performRequest(HttpServletRequest servletRequest, AsyncResponse asyncResponse, Request.Builder requestBuilder, Function<ProxyResponse, Response> responseBuilder) {
setupXForwardedFor(servletRequest, requestBuilder);
setupBearerToken(servletRequest, requestBuilder);
for (String name : list(servletRequest.getHeaderNames())) {
if (isPrestoHeader(name) || name.equalsIgnoreCase(COOKIE)) {
for (String value : list(servletRequest.getHeaders(name))) {
requestBuilder.addHeader(name, value);
}
} else if (name.equalsIgnoreCase(USER_AGENT)) {
for (String value : list(servletRequest.getHeaders(name))) {
requestBuilder.addHeader(name, "[Presto Proxy] " + value);
}
}
}
Request request = requestBuilder.setPreserveAuthorizationOnRedirect(true).build();
ListenableFuture<Response> future = executeHttp(request).transform(responseBuilder::apply, executor).catching(ProxyException.class, e -> handleProxyException(request, e), directExecutor());
setupAsyncResponse(asyncResponse, future);
}
Aggregations