Skip to content

Commit 3beefd9

Browse files
committed
Add support for String parameter types for host and URL path
1 parent 0030d41 commit 3beefd9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

HttpClient.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ HttpClient::HttpClient(Client& aClient, const char* aServerName, uint16_t aServe
1515
resetState();
1616
}
1717

18+
HttpClient::HttpClient(Client& aClient, const String& aServerName, uint16_t aServerPort)
19+
: HttpClient(aClient, aServerName.c_str(), aServerPort)
20+
{
21+
}
22+
1823
HttpClient::HttpClient(Client& aClient, const IPAddress& aServerAddress, uint16_t aServerPort)
1924
: iClient(&aClient), iServerName(NULL), iServerAddress(aServerAddress), iServerPort(aServerPort)
2025
{

HttpClient.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class HttpClient : public Client
4545
// FIXME Update tempToPachube example to calculate Content-Length correctly
4646

4747
HttpClient(Client& aClient, const char* aServerName, uint16_t aServerPort = kHttpPort);
48+
HttpClient(Client& aClient, const String& aServerName, uint16_t aServerPort = kHttpPort);
4849
HttpClient(Client& aClient, const IPAddress& aServerAddress, uint16_t aServerPort = kHttpPort);
4950

5051
/** Start a more complex request.
@@ -66,20 +67,29 @@ class HttpClient : public Client
6667
int get(const char* aURLPath)
6768
{ return startRequest(aURLPath, HTTP_METHOD_GET); }
6869

70+
int get(const String& aURLPath)
71+
{ return get(aURLPath.c_str()); }
72+
6973
/** Connect to the server and start to send a POST request.
7074
@param aURLPath Url to request
7175
@return 0 if successful, else error
7276
*/
7377
int post(const char* aURLPath)
7478
{ return startRequest(aURLPath, HTTP_METHOD_POST); }
7579

80+
int post(const String& aURLPath)
81+
{ return post(aURLPath.c_str()); }
82+
7683
/** Connect to the server and start to send a PUT request.
7784
@param aURLPath Url to request
7885
@return 0 if successful, else error
7986
*/
8087
int put(const char* aURLPath)
8188
{ return startRequest(aURLPath, HTTP_METHOD_PUT); }
8289

90+
int put(const String& aURLPath)
91+
{ return put(aURLPath.c_str()); }
92+
8393
/** Connect to the server and start to send the request.
8494
@param aURLPath Url to request
8595
@param aHttpMethod Type of HTTP request to make, e.g. "GET", "POST", etc.

0 commit comments

Comments
 (0)