Skip to content

Commit 67a66e4

Browse files
committed
fix: global http client to minimalize leaking
1 parent 73c3b0d commit 67a66e4

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

test/TestSupport.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,34 @@
3434

3535
#include "TestSupport.h"
3636

37+
static HTTPClient httpClient;
3738

3839
void printFreeHeap() {
3940
Serial.print("[TD] Free heap: ");
4041
Serial.println(ESP.getFreeHeap());
4142
}
4243

4344
int httpPOST(String url, String mess) {
44-
HTTPClient http;
45-
http.setReuse(false);
45+
httpClient.setReuse(false);
4646
int code = 0;
47-
if(http.begin(url)) {
48-
code = http.POST(mess);
49-
http.end();
47+
if(httpClient.begin(url)) {
48+
code = httpClient.POST(mess);
49+
httpClient.end();
5050
}
5151
return code;
5252
}
5353

5454
int httpGET(String url) {
55-
HTTPClient http;
56-
http.setReuse(false);
55+
httpClient.setReuse(false);
5756
int code = 0;
58-
if(http.begin(url)) {
59-
code = http.GET();
57+
if(httpClient.begin(url)) {
58+
code = httpClient.GET();
6059
if(code != 204) {
6160
//Serial.print("[TD] ");
6261
//String res = http.getString();
6362
//Serial.println(res);
6463
}
65-
http.end();
64+
httpClient.end();
6665
}
6766
return code;
6867
}

0 commit comments

Comments
 (0)