diff --git a/HttpClient.cpp b/HttpClient.cpp index a96ef80..0cbf083 100644 --- a/HttpClient.cpp +++ b/HttpClient.cpp @@ -15,6 +15,11 @@ HttpClient::HttpClient(Client& aClient, const char* aServerName, uint16_t aServe resetState(); } +HttpClient::HttpClient(Client& aClient, const String& aServerName, uint16_t aServerPort) + : HttpClient(aClient, aServerName.c_str(), aServerPort) +{ +} + HttpClient::HttpClient(Client& aClient, const IPAddress& aServerAddress, uint16_t aServerPort) : iClient(&aClient), iServerName(NULL), iServerAddress(aServerAddress), iServerPort(aServerPort) { diff --git a/HttpClient.h b/HttpClient.h index 677bb55..5d48008 100644 --- a/HttpClient.h +++ b/HttpClient.h @@ -45,6 +45,7 @@ public: // FIXME Update tempToPachube example to calculate Content-Length correctly HttpClient(Client& aClient, const char* aServerName, uint16_t aServerPort = kHttpPort); + HttpClient(Client& aClient, const String& aServerName, uint16_t aServerPort = kHttpPort); HttpClient(Client& aClient, const IPAddress& aServerAddress, uint16_t aServerPort = kHttpPort); /** Start a more complex request. @@ -66,6 +67,9 @@ public: int get(const char* aURLPath) { return startRequest(aURLPath, HTTP_METHOD_GET); } + int get(const String& aURLPath) + { return get(aURLPath.c_str()); } + /** Connect to the server and start to send a POST request. @param aURLPath Url to request @return 0 if successful, else error @@ -73,6 +77,9 @@ public: int post(const char* aURLPath) { return startRequest(aURLPath, HTTP_METHOD_POST); } + int post(const String& aURLPath) + { return post(aURLPath.c_str()); } + /** Connect to the server and start to send a PUT request. @param aURLPath Url to request @return 0 if successful, else error @@ -80,6 +87,9 @@ public: int put(const char* aURLPath) { return startRequest(aURLPath, HTTP_METHOD_PUT); } + int put(const String& aURLPath) + { return put(aURLPath.c_str()); } + /** Connect to the server and start to send the request. @param aURLPath Url to request @param aHttpMethod Type of HTTP request to make, e.g. "GET", "POST", etc.