Skip to content

Commit aef1632

Browse files
depsypherkullfar
authored andcommitted
Ensure consistent Content-Encoding header name in Response
Support HttpURLConnection implementations such as the one google appengine uses, which normalizes header names to lower case in the implementation of getHeaderFields().
1 parent c9ac863 commit aef1632

File tree

1 file changed

+9
-2
lines changed
  • scribejava-core/src/main/java/com/github/scribejava/core/model

1 file changed

+9
-2
lines changed

scribejava-core/src/main/java/com/github/scribejava/core/model/Response.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import java.net.HttpURLConnection;
66
import java.net.UnknownHostException;
77
import java.util.HashMap;
8+
import java.util.List;
89
import java.util.Map;
10+
import java.util.Map.Entry;
911
import com.github.scribejava.core.exceptions.OAuthException;
1012
import com.github.scribejava.core.utils.StreamUtils;
1113

@@ -48,8 +50,13 @@ private String parseBodyContents() throws IOException {
4850

4951
private Map<String, String> parseHeaders(HttpURLConnection conn) {
5052
final Map<String, String> headers = new HashMap<>();
51-
for (String key : conn.getHeaderFields().keySet()) {
52-
headers.put(key, conn.getHeaderFields().get(key).get(0));
53+
for (final Entry<String, List<String>> entry : conn.getHeaderFields().entrySet()) {
54+
final String key = entry.getKey();
55+
if ("Content-Encoding".equalsIgnoreCase(key)) {
56+
headers.put("Content-Encoding", entry.getValue().get(0));
57+
} else {
58+
headers.put(key, entry.getValue().get(0));
59+
}
5360
}
5461
return headers;
5562
}

0 commit comments

Comments
 (0)