diff --git a/HttpClient.cpp b/HttpClient.cpp index 2e427e6..0744897 100644 --- a/HttpClient.cpp +++ b/HttpClient.cpp @@ -274,17 +274,22 @@ void HttpClient::sendBasicAuth(const char* aUser, const char* aPassword) void HttpClient::finishHeaders(const char* aContentType, const char* aBody) { - if (aContentType) - sendHeader(HTTP_HEADER_CONTENT_TYPE, aContentType); - - if (aBody) - sendHeader(HTTP_HEADER_CONTENT_LENGTH, strlen(aBody)); - + if (aContentType) + { + sendHeader(HTTP_HEADER_CONTENT_TYPE, aContentType); + } + + if (aBody) + { + sendHeader(HTTP_HEADER_CONTENT_LENGTH, strlen(aBody)); + } + iClient->println(); - - if (aBody) - iClient->println(aBody); - + if (aBody) + { + iClient->println(aBody); + } + iState = eRequestSent; } diff --git a/HttpClient.h b/HttpClient.h index 803c0fe..ef978df 100644 --- a/HttpClient.h +++ b/HttpClient.h @@ -134,8 +134,8 @@ class HttpClient : public Client uint16_t aServerPort, const char* aURLPath, const char* aUserAgent =NULL, - const char* aContentType =NULL, - const char* aBody =NULL) + const char* aContentType =NULL, + const char* aBody =NULL) { return startRequest(aServerName, aServerPort, aURLPath, HTTP_METHOD_POST, aUserAgent, aContentType, aBody); } /** Connect to the server and start to send a POST request. @@ -149,8 +149,8 @@ class HttpClient : public Client int post(const char* aServerName, const char* aURLPath, const char* aUserAgent =NULL, - const char* aContentType =NULL, - const char* aBody =NULL) + const char* aContentType =NULL, + const char* aBody =NULL) { return startRequest(aServerName, kHttpPort, aURLPath, HTTP_METHOD_POST, aUserAgent, aContentType, aBody); } /** Connect to the server and start to send a POST request. This version connects @@ -169,8 +169,8 @@ class HttpClient : public Client uint16_t aServerPort, const char* aURLPath, const char* aUserAgent =NULL, - const char* aContentType =NULL, - const char* aBody =NULL) + const char* aContentType =NULL, + const char* aBody =NULL) { return startRequest(aServerAddress, aServerName, aServerPort, aURLPath, HTTP_METHOD_POST, aUserAgent, aContentType, aBody); } /** Connect to the server and start to send a POST request. This version connects @@ -187,8 +187,8 @@ class HttpClient : public Client const char* aServerName, const char* aURLPath, const char* aUserAgent =NULL, - const char* aContentType =NULL, - const char* aBody =NULL) + const char* aContentType =NULL, + const char* aBody =NULL) { return startRequest(aServerAddress, aServerName, kHttpPort, aURLPath, HTTP_METHOD_POST, aUserAgent, aContentType, aBody); } /** Connect to the server and start to send a PUT request.