Search in sources :

Example 1 with NFRequestContext

use of com.netflix.zuul.context.NFRequestContext in project zuul by Netflix.

the class RibbonCommand method forward.

HttpResponse forward() throws Exception {
    NFRequestContext context = NFRequestContext.getCurrentContext();
    HttpRequest.Builder builder = HttpRequest.newBuilder().verb(verb).uri(uri).entity(requestEntity);
    for (String name : headers.keySet()) {
        List<String> values = headers.get(name);
        for (String value : values) {
            builder.header(name, value);
        }
    }
    for (String name : params.keySet()) {
        List<String> values = params.get(name);
        for (String value : values) {
            builder.queryParams(name, value);
        }
    }
    HttpRequest httpClientRequest = builder.build();
    HttpResponse response = restClient.executeWithLoadBalancer(httpClientRequest);
    context.setZuulResponse(response);
    // chain has already continued without us and therefore won't cleanup itself.
    if (isResponseTimedOut()) {
        response.close();
    }
    return response;
}
Also used : HttpRequest(com.netflix.client.http.HttpRequest) NFRequestContext(com.netflix.zuul.context.NFRequestContext) HttpResponse(com.netflix.client.http.HttpResponse)

Aggregations

HttpRequest (com.netflix.client.http.HttpRequest)1 HttpResponse (com.netflix.client.http.HttpResponse)1 NFRequestContext (com.netflix.zuul.context.NFRequestContext)1