Commit baa50c13 by spccold Committed by Spencer Gibb

simplify org.springframework.cloud.netflix.zuul.filters.ProxyRequestH… (#1965)

* simplify org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper#setResponse * Update ProxyRequestHelper.java
parent 24d0bedf
...@@ -157,30 +157,15 @@ public class ProxyRequestHelper { ...@@ -157,30 +157,15 @@ public class ProxyRequestHelper {
context.setResponseDataStream(entity); context.setResponseDataStream(entity);
} }
HttpHeaders httpHeaders = new HttpHeaders();
for (Entry<String, List<String>> header : headers.entrySet()) {
List<String> values = header.getValue();
for (String value : values) {
httpHeaders.add(header.getKey(), value);
}
}
boolean isOriginResponseGzipped = false; boolean isOriginResponseGzipped = false;
if (httpHeaders.containsKey(CONTENT_ENCODING)) {
List<String> collection = httpHeaders.get(CONTENT_ENCODING);
for (String header : collection) {
if (HTTPRequestUtils.getInstance().isGzipped(header)) {
isOriginResponseGzipped = true;
break;
}
}
}
context.setResponseGZipped(isOriginResponseGzipped);
for (Entry<String, List<String>> header : headers.entrySet()) { for (Entry<String, List<String>> header : headers.entrySet()) {
String name = header.getKey(); String name = header.getKey();
for (String value : header.getValue()) { for (String value : header.getValue()) {
context.addOriginResponseHeader(name, value); if (name.equalsIgnoreCase(HttpHeaders.CONTENT_ENCODING)
if (name.equalsIgnoreCase(CONTENT_LENGTH)) { && HTTPRequestUtils.getInstance().isGzipped(value)) {
isOriginResponseGzipped = true;
}
if (name.equalsIgnoreCase(HttpHeaders.CONTENT_LENGTH)) {
context.setOriginContentLength(value); context.setOriginContentLength(value);
} }
if (isIncludedHeader(name)) { if (isIncludedHeader(name)) {
...@@ -188,6 +173,7 @@ public class ProxyRequestHelper { ...@@ -188,6 +173,7 @@ public class ProxyRequestHelper {
} }
} }
} }
context.setResponseGZipped(isOriginResponseGzipped);
} }
public void addIgnoredHeaders(String... names) { public void addIgnoredHeaders(String... names) {
......
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