Added missing calls to client.stop() in JsonHttpClient.ino (fixes #1485)

This commit is contained in:
Benoit Blanchon
2021-02-01 09:16:23 +01:00
parent ab902128dc
commit c72eccdd35
2 changed files with 5 additions and 0 deletions

View File

@ -5,6 +5,7 @@ HEAD
---- ----
* Made `JsonDocument`'s destructor protected (issue #1480) * Made `JsonDocument`'s destructor protected (issue #1480)
* Added missing calls to `client.stop()` in `JsonHttpClient.ino` (issue #1485)
v6.17.2 (2020-11-14) v6.17.2 (2020-11-14)
------- -------

View File

@ -53,6 +53,7 @@ void setup() {
client.println(F("Connection: close")); client.println(F("Connection: close"));
if (client.println() == 0) { if (client.println() == 0) {
Serial.println(F("Failed to send request")); Serial.println(F("Failed to send request"));
client.stop();
return; return;
} }
@ -63,6 +64,7 @@ void setup() {
if (strcmp(status + 9, "200 OK") != 0) { if (strcmp(status + 9, "200 OK") != 0) {
Serial.print(F("Unexpected response: ")); Serial.print(F("Unexpected response: "));
Serial.println(status); Serial.println(status);
client.stop();
return; return;
} }
@ -70,6 +72,7 @@ void setup() {
char endOfHeaders[] = "\r\n\r\n"; char endOfHeaders[] = "\r\n\r\n";
if (!client.find(endOfHeaders)) { if (!client.find(endOfHeaders)) {
Serial.println(F("Invalid response")); Serial.println(F("Invalid response"));
client.stop();
return; return;
} }
@ -83,6 +86,7 @@ void setup() {
if (error) { if (error) {
Serial.print(F("deserializeJson() failed: ")); Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str()); Serial.println(error.f_str());
client.stop();
return; return;
} }