Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 704b71d

Browse filesBrowse files
authored
Fix header parsing
fixes espressif#4454 closes espressif#4455
1 parent 7c05721 commit 704b71d
Copy full SHA for 704b71d

File tree

1 file changed

+6
-4
lines changed
Filter options

1 file changed

+6
-4
lines changed

‎libraries/HTTPClient/src/HTTPClient.cpp

Copy file name to clipboardExpand all lines: libraries/HTTPClient/src/HTTPClient.cpp
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ int HTTPClient::handleHeaderResponse()
11861186

11871187
_transferEncoding = HTTPC_TE_IDENTITY;
11881188
unsigned long lastDataTime = millis();
1189+
bool firstLine = true;
11891190

11901191
while(connected()) {
11911192
size_t len = _client->available();
@@ -1197,11 +1198,12 @@ int HTTPClient::handleHeaderResponse()
11971198

11981199
log_v("RX: '%s'", headerLine.c_str());
11991200

1200-
if(headerLine.startsWith("HTTP/1.")) {
1201-
if(_canReuse) {
1201+
if(firstLine) {
1202+
if(_canReuse && headerLine.startsWith("HTTP/1.")) {
12021203
_canReuse = (headerLine[sizeof "HTTP/1." - 1] != '0');
12031204
}
1204-
_returnCode = headerLine.substring(9, headerLine.indexOf(' ', 9)).toInt();
1205+
int codePos = headerLine.indexOf(' ') + 1;
1206+
_returnCode = headerLine.substring(codePos, headerLine.indexOf(' ', codePos)).toInt();
12051207
} else if(headerLine.indexOf(':')) {
12061208
String headerName = headerLine.substring(0, headerLine.indexOf(':'));
12071209
String headerValue = headerLine.substring(headerLine.indexOf(':') + 1);
@@ -1450,4 +1452,4 @@ bool HTTPClient::setURL(const String& url)
14501452
const String &HTTPClient::getLocation(void)
14511453
{
14521454
return _location;
1453-
}
1455+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.