Commit 50b53c42 by Ryan Baxter

Merge remote-tracking branch 'origin/1.4.x'

parents bb446cb5 84084fc3
......@@ -161,6 +161,8 @@ public class ProxyRequestHelper {
for (Entry<String, List<String>> header : headers.entrySet()) {
String name = header.getKey();
for (String value : header.getValue()) {
context.addOriginResponseHeader(name, value);
if (name.equalsIgnoreCase(HttpHeaders.CONTENT_ENCODING)
&& HTTPRequestUtils.getInstance().isGzipped(value)) {
isOriginResponseGzipped = true;
......
......@@ -19,6 +19,7 @@ package org.springframework.cloud.netflix.zuul.filters;
import java.io.IOException;
import java.util.List;
import com.netflix.util.Pair;
import com.netflix.zuul.context.RequestContext;
import org.assertj.core.api.Assertions;
import org.junit.After;
......@@ -37,6 +38,7 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
......@@ -227,6 +229,28 @@ public class ProxyRequestHelperTests {
}
@Test
public void setResponseShouldSetOriginResponseHeaders() throws IOException {
MockHttpServletRequest request = new MockHttpServletRequest("POST", "/");
MockHttpServletResponse response = new MockHttpServletResponse();
RequestContext context = RequestContext.getCurrentContext();
context.setRequest(request);
context.setResponse(response);
ProxyRequestHelper helper = new ProxyRequestHelper();
MultiValueMap<String, String> headers = new HttpHeaders();
headers.add(HttpHeaders.CONTENT_TYPE, "text/plain");
headers.add("some-header", "some-value");
helper.setResponse(200, request.getInputStream(), headers);
assertThat(context.getOriginResponseHeaders(), containsInAnyOrder(
new Pair<>(HttpHeaders.CONTENT_TYPE, "text/plain"),
new Pair<>("some-header", "some-value")
));
}
@Test
public void setResponseUppercase() throws IOException {
MockHttpServletRequest request = new MockHttpServletRequest("POST", "/");
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