1
0
mirror of https://github.com/arduino-libraries/ArduinoHttpClient.git synced 2025-04-19 21:22:15 +03:00

Add new beginBody API

This commit is contained in:
Sandeep Mistry 2017-03-28 14:12:20 -04:00
parent 2394bbb7cd
commit 448a1520c8
4 changed files with 15 additions and 1 deletions

View File

@ -58,8 +58,9 @@ void loop() {
client.sendHeader("Content-Type", "application/x-www-form-urlencoded"); client.sendHeader("Content-Type", "application/x-www-form-urlencoded");
client.sendHeader("Content-Length", postData.length()); client.sendHeader("Content-Length", postData.length());
client.sendHeader("X-Custom-Header", "custom-header-value"); client.sendHeader("X-Custom-Header", "custom-header-value");
client.endRequest(); client.beginBody();
client.print(postData); client.print(postData);
client.endRequest();
// read the status code and body of the response // read the status code and body of the response
statusCode = client.responseStatusCode(); statusCode = client.responseStatusCode();

View File

@ -20,6 +20,7 @@ put KEYWORD2
patch KEYWORD2 patch KEYWORD2
startRequest KEYWORD2 startRequest KEYWORD2
beginRequest KEYWORD2 beginRequest KEYWORD2
beginBody KEYWORD2
sendHeader KEYWORD2 sendHeader KEYWORD2
sendBasicAuth KEYWORD2 sendBasicAuth KEYWORD2
endRequest KEYWORD2 endRequest KEYWORD2

View File

@ -263,6 +263,11 @@ void HttpClient::flushClientRx()
} }
void HttpClient::endRequest() void HttpClient::endRequest()
{
beginBody();
}
void HttpClient::beginBody()
{ {
if (iState < eRequestSent) if (iState < eRequestSent)
{ {

View File

@ -62,6 +62,13 @@ public:
*/ */
void endRequest(); void endRequest();
/** Start the body of a more complex request.
Use this when you need to send the body after additional headers
in the request, but can optionally call endRequest() when
you are finished.
*/
void beginBody();
/** Connect to the server and start to send a GET request. /** Connect to the server and start to send a GET request.
@param aURLPath Url to request @param aURLPath Url to request
@return 0 if successful, else error @return 0 if successful, else error