1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-12 01:53:07 +03:00

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.
This commit is contained in:
Mick Wheeler
2018-10-04 13:50:48 +01:00
committed by Earle F. Philhower, III
parent 14808c9ac4
commit 1de0c341b5

View File

@ -1041,8 +1041,13 @@ int HTTPClient::handleHeaderResponse()
for(size_t i = 0; i < _headerKeysCount; i++) {
if(_currentHeaders[i].key.equalsIgnoreCase(headerName)) {
_currentHeaders[i].value = headerValue;
break;
if (_currentHeaders[i].value != "") {
// Existing value, append this one with a comma
_currentHeaders[i].value += "," + headerValue;
} else {
_currentHeaders[i].value = headerValue;
}
break; // We found a match, stop looking
}
}
}