From 1de0c341b55ba8c0993fd3d2e0c5696935578751 Mon Sep 17 00:00:00 2001 From: Mick Wheeler Date: Thu, 4 Oct 2018 13:50:48 +0100 Subject: [PATCH] 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. --- libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index f04a1d704..7db0e72c6 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -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 } } }