@@ -21,7 +21,7 @@ void setup()
2121
2222const char * fp = " 40 A3 6C E3 8A DF A2 D4 13 B0 32 5C 87 44 54 28 0B CE C5 A4" ;
2323
24- TEST_CASE (" HTTP GET request " , " [HTTPClient]" )
24+ TEST_CASE (" HTTP GET & POST requests " , " [HTTPClient]" )
2525{
2626 {
2727 // small request
@@ -47,7 +47,20 @@ TEST_CASE("HTTP GET request", "[HTTPClient]")
4747 }
4848 }
4949 }
50+ {
51+ // can do two POST requests with one HTTPClient object (#1902)
52+ HTTPClient http;
53+ http.begin (SERVER_IP, 8088 , " /" );
54+ http.addHeader (" Content-Type" , " text/plain" );
55+ auto httpCode = http.POST (" foo" );
56+ Serial.println (httpCode);
57+ REQUIRE (httpCode == HTTP_CODE_OK);
58+ http.end ();
5059
60+ httpCode = http.POST (" bar" );
61+ REQUIRE (httpCode == HTTP_CODE_OK);
62+ http.end ();
63+ }
5164}
5265
5366
@@ -79,57 +92,6 @@ TEST_CASE("HTTPS GET request", "[HTTPClient]")
7992 }
8093
8194}
82- // TEST_CASE("HTTP GET request", "[HTTPClient]")
83- // {
84- // const int repeatCount = 10;
85-
86- // String url = createBin(false);
87- // int heapBefore = ESP.getFreeHeap();
88- // for (int i = 0; i < repeatCount; ++i) {
89- // HTTPClient http;
90- // http.begin(url);
91- // auto httpCode = http.GET();
92- // REQUIRE(httpCode == HTTP_CODE_OK);
93- // String payload = http.getString();
94- // payload.replace("\n", "\\n");
95- // String quotedPayload;
96- // quotedPayload.reserve(payload.length() + 3);
97- // quotedPayload += "\"";
98- // quotedPayload += payload;
99- // quotedPayload += "\"";
100- // Serial.println("----payload:");
101- // Serial.println(quotedPayload);
102- // Serial.println("----");
103- // Serial.println("----test_payload:");
104- // Serial.println(test_payload);
105- // Serial.println("----");
106- // CHECK(quotedPayload == test_payload);
107- // http.end();
108- // delay(100);
109- // }
110- // int heapAfter = ESP.getFreeHeap();
111- // CHECK(heapBefore - heapAfter <= 8);
112- // }
113-
114- // TEST_CASE("HTTPS GET request", "[HTTPClient]")
115- // {
116- // const int repeatCount = 10;
117-
118- // String url = createBin(true);
119- // int heapBefore = ESP.getFreeHeap();
120- // for (int i = 0; i < repeatCount; ++i) {
121- // HTTPClient http;
122- // http.begin(url, mockbin_fingerprint);
123- // auto httpCode = http.GET();
124- // REQUIRE(httpCode == HTTP_CODE_OK);
125- // String payload = http.getString();
126- // CHECK(payload == test_payload);
127- // http.end();
128- // delay(100);
129- // }
130- // int heapAfter = ESP.getFreeHeap();
131- // CHECK(heapBefore - heapAfter <= 8);
132- // }
13395
13496void loop ()
13597{
0 commit comments