Ignore null-keyed entries when iterating through the response headers

This commit is contained in:
Mauricio Colli 2020-02-29 17:59:51 -03:00 committed by TobiGr
parent 5edd774fc4
commit f66c20de54
1 changed files with 2 additions and 1 deletions

View File

@ -68,7 +68,8 @@ public class Response {
@Nullable @Nullable
public String getHeader(String name) { public String getHeader(String name) {
for (Map.Entry<String, List<String>> headerEntry : responseHeaders.entrySet()) { for (Map.Entry<String, List<String>> headerEntry : responseHeaders.entrySet()) {
if (headerEntry.getKey().equalsIgnoreCase(name)) { final String key = headerEntry.getKey();
if (key != null && key.equalsIgnoreCase(name)) {
if (headerEntry.getValue().size() > 0) { if (headerEntry.getValue().size() > 0) {
return headerEntry.getValue().get(0); return headerEntry.getValue().get(0);
} }