mirror of
https://github.com/arduino-libraries/ArduinoHttpClient.git
synced 2025-04-19 21:22:15 +03:00
Always finish headers if a request body is provided to startRequest
This commit is contained in:
parent
f56eecbc6f
commit
8f42a68a50
@ -118,18 +118,20 @@ int HttpClient::startRequest(const char* aURLPath, const char* aHttpMethod,
|
|||||||
sendHeader(HTTP_HEADER_CONTENT_LENGTH, aContentLength);
|
sendHeader(HTTP_HEADER_CONTENT_LENGTH, aContentLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((initialState == eIdle))
|
bool hasBody = (aBody && aContentLength > 0);
|
||||||
|
|
||||||
|
if (initialState == eIdle || hasBody)
|
||||||
{
|
{
|
||||||
// This was a simple version of the API, so terminate the headers now
|
// This was a simple version of the API, so terminate the headers now
|
||||||
finishHeaders();
|
finishHeaders();
|
||||||
|
}
|
||||||
|
// else we'll call it in endRequest or in the first call to print, etc.
|
||||||
|
|
||||||
if (aBody && aContentLength > 0)
|
if (hasBody)
|
||||||
{
|
{
|
||||||
write(aBody, aContentLength);
|
write(aBody, aContentLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else we'll call it in endRequest or in the first call to print, etc.
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public:
|
|||||||
int post(const char* aURLPath);
|
int post(const char* aURLPath);
|
||||||
int post(const String& aURLPath);
|
int post(const String& aURLPath);
|
||||||
|
|
||||||
/** Connect to the server and start to send a POST request
|
/** Connect to the server and send a POST request
|
||||||
with body and content type
|
with body and content type
|
||||||
@param aURLPath Url to request
|
@param aURLPath Url to request
|
||||||
@param aContentType Content type of request body
|
@param aContentType Content type of request body
|
||||||
@ -93,7 +93,7 @@ public:
|
|||||||
int put(const char* aURLPath);
|
int put(const char* aURLPath);
|
||||||
int put(const String& aURLPath);
|
int put(const String& aURLPath);
|
||||||
|
|
||||||
/** Connect to the server and start to send a PUT request
|
/** Connect to the server and send a PUT request
|
||||||
with body and content type
|
with body and content type
|
||||||
@param aURLPath Url to request
|
@param aURLPath Url to request
|
||||||
@param aContentType Content type of request body
|
@param aContentType Content type of request body
|
||||||
@ -111,7 +111,7 @@ public:
|
|||||||
int del(const char* aURLPath);
|
int del(const char* aURLPath);
|
||||||
int del(const String& aURLPath);
|
int del(const String& aURLPath);
|
||||||
|
|
||||||
/** Connect to the server and start to send a DELETE request
|
/** Connect to the server and send a DELETE request
|
||||||
with body and content type
|
with body and content type
|
||||||
@param aURLPath Url to request
|
@param aURLPath Url to request
|
||||||
@param aContentType Content type of request body
|
@param aContentType Content type of request body
|
||||||
@ -123,6 +123,7 @@ public:
|
|||||||
int del(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]);
|
int del(const char* aURLPath, const char* aContentType, int aContentLength, const byte aBody[]);
|
||||||
|
|
||||||
/** Connect to the server and start to send the request.
|
/** Connect to the server and start to send the request.
|
||||||
|
If a body is provided, the entire request (including headers and body) will be sent
|
||||||
@param aURLPath Url to request
|
@param aURLPath Url to request
|
||||||
@param aHttpMethod Type of HTTP request to make, e.g. "GET", "POST", etc.
|
@param aHttpMethod Type of HTTP request to make, e.g. "GET", "POST", etc.
|
||||||
@param aContentType Content type of request body (optional)
|
@param aContentType Content type of request body (optional)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user