Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow control over authorization String allocation #8225

Merged
merged 4 commits into from
Sep 4, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,26 @@ void HTTPClient::setAuthorization(const char * user, const char * password)
}

/**
* set the Authorizatio for the http request
* set the Authorization for the http request
* @param auth const char * base64
*/
void HTTPClient::setAuthorization(const char * auth)
{
if(auth) {
_base64Authorization = auth;
_base64Authorization.replace(String('\n'), emptyString);
if (auth) {
setAuthorization(String(auth));
}
}

/**
* set the Authorization for the http request
* @param auth String base64
*/
void HTTPClient::setAuthorization(String auth)
{
_base64Authorization = std::move(auth);
_base64Authorization.replace(String('\n'), emptyString);
}

/**
* set the timeout for the TCP connection
* @param timeout unsigned int
Expand Down
1 change: 1 addition & 0 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class HTTPClient
void setUserAgent(const String& userAgent);
void setAuthorization(const char * user, const char * password);
void setAuthorization(const char * auth);
void setAuthorization(String auth);
void setTimeout(uint16_t timeout);

// Redirections
Expand Down