Skip to content

Commit 7367117

Browse files
committed
- Updated vector.push_back to .emplace_back to avoid unnecessary copies.
- Updated int port to uint16_t
1 parent 6557c7e commit 7367117

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/R4HttpClient.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void R4HttpClient::begin(const WiFiSSLClient &sslClient, const String &url)
2828
* @params: sslClient, url, nport
2929
* @Description: Initializes client, url, port. Then, extracts the url to get the host, then the endpoint in which where it will do the post request
3030
*/
31-
void R4HttpClient::begin(const WiFiSSLClient &sslClient, const String &url, const int &nport)
31+
void R4HttpClient::begin(const WiFiSSLClient &sslClient, const String &url, const uint16_t &nport)
3232
{
3333
this->client = sslClient;
3434
this->setPort(nport);
@@ -55,7 +55,7 @@ void R4HttpClient::extractUrlComponents(const String &url)
5555
this->endpoint = (endpointIndex == -1) ? "/" : url.substring(endpointIndex);
5656
}
5757

58-
void R4HttpClient::setPort(const int &nport)
58+
void R4HttpClient::setPort(const uint16_t &nport)
5959
{
6060
this->port = nport;
6161
}

src/R4HttpClient.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ enum ResponseState
109109
class R4HttpClient
110110
{
111111
private:
112-
int port;
112+
uint16_t port;
113113
String host;
114114
String endpoint;
115115
String body;
@@ -118,7 +118,7 @@ class R4HttpClient
118118
std::vector<String> headers;
119119

120120
void extractUrlComponents(const String &url);
121-
void setPort(const int &nport);
121+
void setPort(const uint16_t &nport);
122122
int sendRequest(const String &method, const String &requestBody);
123123

124124
// disable copy constructor and assignment operator
@@ -130,7 +130,7 @@ class R4HttpClient
130130
~R4HttpClient();
131131

132132
void begin(const WiFiSSLClient &sslClient, const String &url);
133-
void begin(const WiFiSSLClient &sslClient, const String &url, const int &nport);
133+
void begin(const WiFiSSLClient &sslClient, const String &url, const uint16_t &nport);
134134
void addHeader(const String &content);
135135
void setTimeout(const int &ms);
136136
void setDebug(const bool &debug);

0 commit comments

Comments
 (0)