Example usage for io.vertx.core.http.impl HttpClientRequestImpl headers

List of usage examples for io.vertx.core.http.impl HttpClientRequestImpl headers

Introduction

In this page you can find the example usage for io.vertx.core.http.impl HttpClientRequestImpl headers.

Prototype

VertxHttpHeaders headers

To view the source code for io.vertx.core.http.impl HttpClientRequestImpl headers.

Click Source Link

Usage

From source file:io.helixservice.feature.context.RequestContextAspect.java

License:Open Source License

/**
 * Weave in logic just before sending a request to copy any headers we should forward into the outgoing request
 *//* ww w  .  ja  va 2 s. c o m*/
@Around(value = "(execution(private void io.vertx.core.http.impl.HttpClientRequestImpl.prepareHeaders())) "
        + "&& this(httpClientRequestImpl)", argNames = "pjp, httpClientRequestImpl")
public void aroundPrepareHeaders(ProceedingJoinPoint pjp, HttpClientRequestImpl httpClientRequestImpl)
        throws Throwable, SuspendExecution {

    RequestContext context = RequestContext.getContext();
    if (context != null && !requestContextFeature.propagateHeaders.isEmpty()) {
        MultiMap headers = httpClientRequestImpl.headers();

        for (Map.Entry<String, String> contextHeaderEntry : requestContextFeature.propagateHeaders.entrySet()) {
            String value = context.getValue(contextHeaderEntry.getKey());
            if (value != null) {
                headers.set(contextHeaderEntry.getValue(), value);
            }
        }
    }

    pjp.proceed();
}