Search in sources :

Example 1 with WebClientRequestHeaders

use of io.helidon.webclient.WebClientRequestHeaders in project helidon by oracle.

the class WebClientSecurity method processResponse.

private WebClientServiceRequest processResponse(WebClientServiceRequest request, Span span, OutboundSecurityResponse providerResponse) {
    try {
        switch(providerResponse.status()) {
            case FAILURE:
            case FAILURE_FINISH:
                traceError(span, providerResponse.throwable().orElse(null), providerResponse.description().orElse(providerResponse.status().toString()));
                break;
            case ABSTAIN:
            case SUCCESS:
            case SUCCESS_FINISH:
            default:
                break;
        }
        Map<String, List<String>> newHeaders = providerResponse.requestHeaders();
        LOGGER.finest(() -> "Client filter header(s). SIZE: " + newHeaders.size());
        WebClientRequestHeaders clientHeaders = request.headers();
        for (Map.Entry<String, List<String>> entry : newHeaders.entrySet()) {
            LOGGER.finest(() -> "    + Header: " + entry.getKey() + ": " + entry.getValue());
            // replace existing
            clientHeaders.remove(entry.getKey());
            for (String value : entry.getValue()) {
                clientHeaders.put(entry.getKey(), value);
            }
        }
        span.finish();
        return request;
    } catch (Exception e) {
        traceError(span, e, null);
        throw e;
    }
}
Also used : WebClientRequestHeaders(io.helidon.webclient.WebClientRequestHeaders) List(java.util.List) Map(java.util.Map)

Example 2 with WebClientRequestHeaders

use of io.helidon.webclient.WebClientRequestHeaders in project helidon by oracle.

the class RestApiBase method addHeaders.

/**
 * Add HTTP headers.
 * This method adds headers configured on the provided {@link io.helidon.integrations.common.rest.ApiRequest}.
 *
 * @param requestBuilder web client request builder to configure headers on
 * @param path requested path
 * @param request API request
 * @param method HTTP method
 * @param requestId request ID
 */
protected void addHeaders(WebClientRequestBuilder requestBuilder, String path, ApiRequest<?> request, Http.RequestMethod method, String requestId) {
    WebClientRequestHeaders headers = requestBuilder.headers();
    request.headers().forEach(headers::add);
}
Also used : WebClientRequestHeaders(io.helidon.webclient.WebClientRequestHeaders)

Aggregations

WebClientRequestHeaders (io.helidon.webclient.WebClientRequestHeaders)2 List (java.util.List)1 Map (java.util.Map)1