1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Allow control over HTTPClient authorization String allocation (#8225)

This commit is contained in:
Paulo Cabral Sanz 2021-09-04 14:17:00 -03:00 committed by GitHub
parent 65db3aec72
commit 058ce7c08e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -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 * @param auth const char * base64
*/ */
void HTTPClient::setAuthorization(const char * auth) void HTTPClient::setAuthorization(const char * auth)
{ {
if (auth) { if (auth) {
_base64Authorization = auth; setAuthorization(String(auth));
_base64Authorization.replace(String('\n'), emptyString);
} }
} }
/**
* 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 * set the timeout for the TCP connection
* @param timeout unsigned int * @param timeout unsigned int

View File

@ -176,6 +176,7 @@ public:
void setUserAgent(const String& userAgent); void setUserAgent(const String& userAgent);
void setAuthorization(const char * user, const char * password); void setAuthorization(const char * user, const char * password);
void setAuthorization(const char * auth); void setAuthorization(const char * auth);
void setAuthorization(String auth);
void setTimeout(uint16_t timeout); void setTimeout(uint16_t timeout);
// Redirections // Redirections