use of com.netflix.zuul.message.Headers in project zuul by Netflix.
the class GZipResponseFilter method apply.
@Override
public HttpResponseMessage apply(HttpResponseMessage response) {
// set Gzip headers
final Headers respHeaders = response.getHeaders();
respHeaders.set(HttpHeaderNames.CONTENT_ENCODING, "gzip");
respHeaders.remove(HttpHeaderNames.CONTENT_LENGTH);
return response;
}
use of com.netflix.zuul.message.Headers in project zuul by Netflix.
the class ProxyEndpoint method transformRequest.
/* static utility methods */
protected HttpRequestMessage transformRequest(HttpRequestMessage requestMsg) {
final HttpRequestMessage massagedRequest = massageRequestURI(requestMsg);
Headers headers = massagedRequest.getHeaders();
REQUEST_HEADERS_TO_REMOVE.forEach(headerName -> headers.remove(headerName.getName()));
addCustomRequestHeaders(headers);
// Add X-Forwarded headers if not already there.
ProxyUtils.addXForwardedHeaders(massagedRequest);
return massagedRequest;
}
use of com.netflix.zuul.message.Headers in project zuul by Netflix.
the class HttpRequestMessageImplTest method getOriginalPort_fallsBackOnUnbracketedIpv6Address.
@Test
public void getOriginalPort_fallsBackOnUnbracketedIpv6Address() throws URISyntaxException {
Headers headers = new Headers();
headers.add("Host", "ba::33");
assertEquals(9999, HttpRequestMessageImpl.getOriginalPort(new SessionContext(), headers, 9999));
}
use of com.netflix.zuul.message.Headers in project zuul by Netflix.
the class HttpRequestMessageImplTest method testOriginalRequestInfo.
@Test
public void testOriginalRequestInfo() {
HttpQueryParams queryParams = new HttpQueryParams();
queryParams.add("flag", "5");
Headers headers = new Headers();
headers.add("Host", "blah.netflix.com");
request = new HttpRequestMessageImpl(new SessionContext(), "HTTP/1.1", "POST", "/some/where", queryParams, headers, "192.168.0.2", "https", 7002, "localhost", new LocalAddress("777"), false);
request.storeInboundRequest();
HttpRequestInfo originalRequest = request.getInboundRequest();
Assert.assertEquals(request.getPort(), originalRequest.getPort());
Assert.assertEquals(request.getPath(), originalRequest.getPath());
Assert.assertEquals(request.getQueryParams().getFirst("flag"), originalRequest.getQueryParams().getFirst("flag"));
Assert.assertEquals(request.getHeaders().getFirst("Host"), originalRequest.getHeaders().getFirst("Host"));
request.setPort(8080);
request.setPath("/another/place");
request.getQueryParams().set("flag", "20");
request.getHeaders().set("Host", "wah.netflix.com");
Assert.assertEquals(7002, originalRequest.getPort());
Assert.assertEquals("/some/where", originalRequest.getPath());
Assert.assertEquals("5", originalRequest.getQueryParams().getFirst("flag"));
Assert.assertEquals("blah.netflix.com", originalRequest.getHeaders().getFirst("Host"));
}
use of com.netflix.zuul.message.Headers in project zuul by Netflix.
the class HttpRequestMessageImplTest method testReconstructURI_immutable.
@Test
public void testReconstructURI_immutable() {
HttpQueryParams queryParams = new HttpQueryParams();
queryParams.add("flag", "5");
Headers headers = new Headers();
headers.add("Host", "blah.netflix.com");
request = new HttpRequestMessageImpl(new SessionContext(), "HTTP/1.1", "POST", "/some/where", queryParams, headers, "192.168.0.2", "https", 7002, "localhost", new SocketAddress() {
}, true);
// Check it's the same value 2nd time.
Assert.assertEquals("https://blah.netflix.com:7002/some/where?flag=5", request.reconstructURI());
Assert.assertEquals("https://blah.netflix.com:7002/some/where?flag=5", request.reconstructURI());
// Check that cached on 1st usage.
request = new HttpRequestMessageImpl(new SessionContext(), "HTTP/1.1", "POST", "/some/where", queryParams, headers, "192.168.0.2", "https", 7002, "localhost", new SocketAddress() {
}, true);
request = spy(request);
when(request._reconstructURI()).thenReturn("http://testhost/blah");
verify(request, times(1))._reconstructURI();
Assert.assertEquals("http://testhost/blah", request.reconstructURI());
Assert.assertEquals("http://testhost/blah", request.reconstructURI());
// Check that throws exception if we try to mutate it.
try {
request.setPath("/new-path");
fail();
} catch (IllegalStateException e) {
assertTrue(true);
}
}
Aggregations