Unverified Commit 381a0970 by Ryan Baxter Committed by GitHub

Does not set accept-encoding header when zuul proxies request if already…

Does not set accept-encoding header when zuul proxies request if already present. Fixes #2998 (#3011)
parent 0970a3ef
...@@ -145,7 +145,9 @@ public class ProxyRequestHelper { ...@@ -145,7 +145,9 @@ public class ProxyRequestHelper {
for (String header : zuulRequestHeaders.keySet()) { for (String header : zuulRequestHeaders.keySet()) {
headers.set(header, zuulRequestHeaders.get(header)); headers.set(header, zuulRequestHeaders.get(header));
} }
if(!headers.containsKey(HttpHeaders.ACCEPT_ENCODING)) {
headers.set(HttpHeaders.ACCEPT_ENCODING, "gzip"); headers.set(HttpHeaders.ACCEPT_ENCODING, "gzip");
}
return headers; return headers;
} }
......
...@@ -212,6 +212,20 @@ public class ProxyRequestHelperTests { ...@@ -212,6 +212,20 @@ public class ProxyRequestHelperTests {
} }
@Test @Test
public void buildZuulRequestHeadersRequestsAcceptEncoding() {
MockHttpServletRequest request = new MockHttpServletRequest("", "/");
request.addHeader("accept-encoding", "identity");
ProxyRequestHelper helper = new ProxyRequestHelper();
MultiValueMap<String, String> headers = helper.buildZuulRequestHeaders(request);
List<String> acceptEncodings = headers.get("accept-encoding");
assertThat(acceptEncodings, hasSize(1));
assertThat(acceptEncodings, contains("identity"));
}
@Test
public void setResponseLowercase() throws IOException { public void setResponseLowercase() throws IOException {
MockHttpServletRequest request = new MockHttpServletRequest("POST", "/"); MockHttpServletRequest request = new MockHttpServletRequest("POST", "/");
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment