Search in sources :

Example 1 with MultiMap

use of org.vertx.java.core.MultiMap in project fabric8 by jboss-fuse.

the class HttpGatewayTest method testENTESB7600.

@Test
public void testENTESB7600() throws Exception {
    // response can not contain CONTENT_LENGTH and TRANSFER_ENCODING see https://tools.ietf.org/html/rfc7230#section-3.3.3
    startRestEndpoint();
    startHttpGateway();
    System.out.println("Requesting...");
    final FutureHandler<HttpClientResponse> future = new FutureHandler<>();
    vertx.createHttpClient().setHost("localhost").setPort(8080).get("/hello/world?wsdl", new Handler<HttpClientResponse>() {

        @Override
        public void handle(HttpClientResponse event) {
            future.handle(event);
        }
    }).end();
    MultiMap responseHeaders = future.await().headers();
    assertTrue((responseHeaders.contains(CONTENT_LENGTH) && !responseHeaders.contains(TRANSFER_ENCODING)) || (!responseHeaders.contains(CONTENT_LENGTH) && responseHeaders.contains(TRANSFER_ENCODING)));
    stopHttpGateway();
    stopVertx();
}
Also used : MultiMap(org.vertx.java.core.MultiMap) HttpClientResponse(org.vertx.java.core.http.HttpClientResponse) HttpGatewayHandler(io.fabric8.gateway.handlers.http.HttpGatewayHandler) FutureHandler(io.fabric8.gateway.handlers.detecting.FutureHandler) Handler(org.vertx.java.core.Handler) FutureHandler(io.fabric8.gateway.handlers.detecting.FutureHandler) Test(org.junit.Test)

Example 2 with MultiMap

use of org.vertx.java.core.MultiMap in project fabric8 by jboss-fuse.

the class ReverseUriPolicy method handle.

@Override
public void handle(HttpClientResponse clientResponse) {
    delegate.handle(clientResponse);
    MultiMap headers = clientResponse.headers();
    for (String headerName : rewriteHeaders) {
        List<String> headerValues = headers.getAll(headerName);
        int size = headerValues.size();
        if (size > 0) {
            List<String> newHeaders = new ArrayList<String>(size);
            for (String headerValue : headerValues) {
                String newValue = headerValue;
                if (headerValue != null && headerValue.length() > 0) {
                    newValue = proxyMappingDetails.rewriteBackendUrl(headerValue);
                }
            }
            LOG.info("Rewriting header " + headerName + " from: " + headerValues + " to: " + newHeaders);
            headers.set(headerName, newHeaders);
        }
    }
}
Also used : MultiMap(org.vertx.java.core.MultiMap) ArrayList(java.util.ArrayList)

Aggregations

MultiMap (org.vertx.java.core.MultiMap)2 FutureHandler (io.fabric8.gateway.handlers.detecting.FutureHandler)1 HttpGatewayHandler (io.fabric8.gateway.handlers.http.HttpGatewayHandler)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Handler (org.vertx.java.core.Handler)1 HttpClientResponse (org.vertx.java.core.http.HttpClientResponse)1