Skip to content

Commit 448a152

Browse files
committed
Add new beginBody API
1 parent 2394bbb commit 448a152

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

examples/PostWithHeaders/PostWithHeaders.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ void loop() {
5858
client.sendHeader("Content-Type", "application/x-www-form-urlencoded");
5959
client.sendHeader("Content-Length", postData.length());
6060
client.sendHeader("X-Custom-Header", "custom-header-value");
61-
client.endRequest();
61+
client.beginBody();
6262
client.print(postData);
63+
client.endRequest();
6364

6465
// read the status code and body of the response
6566
statusCode = client.responseStatusCode();

keywords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ put KEYWORD2
2020
patch KEYWORD2
2121
startRequest KEYWORD2
2222
beginRequest KEYWORD2
23+
beginBody KEYWORD2
2324
sendHeader KEYWORD2
2425
sendBasicAuth KEYWORD2
2526
endRequest KEYWORD2

src/HttpClient.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ void HttpClient::flushClientRx()
263263
}
264264

265265
void HttpClient::endRequest()
266+
{
267+
beginBody();
268+
}
269+
270+
void HttpClient::beginBody()
266271
{
267272
if (iState < eRequestSent)
268273
{

src/HttpClient.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ class HttpClient : public Client
6262
*/
6363
void endRequest();
6464

65+
/** Start the body of a more complex request.
66+
Use this when you need to send the body after additional headers
67+
in the request, but can optionally call endRequest() when
68+
you are finished.
69+
*/
70+
void beginBody();
71+
6572
/** Connect to the server and start to send a GET request.
6673
@param aURLPath Url to request
6774
@return 0 if successful, else error

0 commit comments

Comments
 (0)