Search in sources :

Example 1 with HttpRequest

use of io.vertx.reactivex.ext.web.client.HttpRequest in project knotx by Cognifide.

the class HttpClientFacade method updateRequestHeaders.

private void updateRequestHeaders(HttpRequest<Buffer> request, ClientRequest serviceRequest, ServiceMetadata serviceMetadata) {
    MultiMap filteredHeaders = getFilteredHeaders(serviceRequest.getHeaders(), serviceMetadata.getAllowedRequestHeaderPatterns());
    filteredHeaders.names().forEach(headerName -> filteredHeaders.getAll(headerName).forEach(value -> request.headers().add(headerName, value)));
    if (customRequestHeader.containsKey("name") && customRequestHeader.containsKey("value")) {
        request.headers().set(customRequestHeader.getString("name"), customRequestHeader.getString("value"));
    }
}
Also used : HttpResponse(io.vertx.reactivex.ext.web.client.HttpResponse) UnsupportedServiceException(io.knotx.adapter.common.exception.UnsupportedServiceException) MultiMapCollector(io.knotx.http.MultiMapCollector) Single(io.reactivex.Single) LoggerFactory(io.vertx.core.logging.LoggerFactory) WebClient(io.vertx.reactivex.ext.web.client.WebClient) AdapterServiceContractException(io.knotx.adapter.common.exception.AdapterServiceContractException) ClientResponse(io.knotx.dataobjects.ClientResponse) DataObjectsUtil(io.knotx.util.DataObjectsUtil) MultiMap(io.vertx.reactivex.core.MultiMap) List(java.util.List) AdapterRequest(io.knotx.dataobjects.AdapterRequest) Pair(org.apache.commons.lang3.tuple.Pair) UriTransformer(io.knotx.adapter.common.placeholders.UriTransformer) AllowedHeadersFilter(io.knotx.http.AllowedHeadersFilter) HttpMethod(io.vertx.core.http.HttpMethod) ClientRequest(io.knotx.dataobjects.ClientRequest) HttpRequest(io.vertx.reactivex.ext.web.client.HttpRequest) Optional(java.util.Optional) JsonObject(io.vertx.core.json.JsonObject) Pattern(java.util.regex.Pattern) Logger(io.vertx.core.logging.Logger) Buffer(io.vertx.reactivex.core.buffer.Buffer) MultiMap(io.vertx.reactivex.core.MultiMap)

Aggregations

AdapterServiceContractException (io.knotx.adapter.common.exception.AdapterServiceContractException)1 UnsupportedServiceException (io.knotx.adapter.common.exception.UnsupportedServiceException)1 UriTransformer (io.knotx.adapter.common.placeholders.UriTransformer)1 AdapterRequest (io.knotx.dataobjects.AdapterRequest)1 ClientRequest (io.knotx.dataobjects.ClientRequest)1 ClientResponse (io.knotx.dataobjects.ClientResponse)1 AllowedHeadersFilter (io.knotx.http.AllowedHeadersFilter)1 MultiMapCollector (io.knotx.http.MultiMapCollector)1 DataObjectsUtil (io.knotx.util.DataObjectsUtil)1 Single (io.reactivex.Single)1 HttpMethod (io.vertx.core.http.HttpMethod)1 JsonObject (io.vertx.core.json.JsonObject)1 Logger (io.vertx.core.logging.Logger)1 LoggerFactory (io.vertx.core.logging.LoggerFactory)1 MultiMap (io.vertx.reactivex.core.MultiMap)1 Buffer (io.vertx.reactivex.core.buffer.Buffer)1 HttpRequest (io.vertx.reactivex.ext.web.client.HttpRequest)1 HttpResponse (io.vertx.reactivex.ext.web.client.HttpResponse)1 WebClient (io.vertx.reactivex.ext.web.client.WebClient)1 List (java.util.List)1