Skip to content

Commit 1de0c34

Browse files
Mick Wheelerearlephilhower
Mick Wheeler
authored andcommitted
Support for concatenation of headers (#4864)
If the server returns several headers of the same key (e.g Set-Cookie) only the last one is returned, causing issues in communicating with some servers where cookies are required. This change concatenates the headers of the same key separated by "," to alleviate this issue.
1 parent 14808c9 commit 1de0c34

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,13 @@ int HTTPClient::handleHeaderResponse()
10411041

10421042
for(size_t i = 0; i < _headerKeysCount; i++) {
10431043
if(_currentHeaders[i].key.equalsIgnoreCase(headerName)) {
1044-
_currentHeaders[i].value = headerValue;
1045-
break;
1044+
if (_currentHeaders[i].value != "") {
1045+
// Existing value, append this one with a comma
1046+
_currentHeaders[i].value += "," + headerValue;
1047+
} else {
1048+
_currentHeaders[i].value = headerValue;
1049+
}
1050+
break; // We found a match, stop looking
10461051
}
10471052
}
10481053
}

0 commit comments

Comments
 (0)