File tree 1 file changed +6
-4
lines changed
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -1186,6 +1186,7 @@ int HTTPClient::handleHeaderResponse()
1186
1186
1187
1187
_transferEncoding = HTTPC_TE_IDENTITY;
1188
1188
unsigned long lastDataTime = millis ();
1189
+ bool firstLine = true ;
1189
1190
1190
1191
while (connected ()) {
1191
1192
size_t len = _client->available ();
@@ -1197,11 +1198,12 @@ int HTTPClient::handleHeaderResponse()
1197
1198
1198
1199
log_v (" RX: '%s'" , headerLine.c_str ());
1199
1200
1200
- if (headerLine. startsWith ( " HTTP/1. " ) ) {
1201
- if (_canReuse) {
1201
+ if (firstLine ) {
1202
+ if (_canReuse && headerLine. startsWith ( " HTTP/1. " ) ) {
1202
1203
_canReuse = (headerLine[sizeof " HTTP/1." - 1 ] != ' 0' );
1203
1204
}
1204
- _returnCode = headerLine.substring (9 , headerLine.indexOf (' ' , 9 )).toInt ();
1205
+ int codePos = headerLine.indexOf (' ' ) + 1 ;
1206
+ _returnCode = headerLine.substring (codePos, headerLine.indexOf (' ' , codePos)).toInt ();
1205
1207
} else if (headerLine.indexOf (' :' )) {
1206
1208
String headerName = headerLine.substring (0 , headerLine.indexOf (' :' ));
1207
1209
String headerValue = headerLine.substring (headerLine.indexOf (' :' ) + 1 );
@@ -1450,4 +1452,4 @@ bool HTTPClient::setURL(const String& url)
1450
1452
const String &HTTPClient::getLocation (void )
1451
1453
{
1452
1454
return _location;
1453
- }
1455
+ }
You can’t perform that action at this time.
0 commit comments