[web_server_idf] Add const char* overloads for getParam/hasParam to avoid temporary string allocations (#13746)

This commit is contained in:
J. Nick Koston
2026-02-03 16:43:27 +01:00
committed by GitHub
parent 18f7e0e6b3
commit b8b072cf86
4 changed files with 20 additions and 15 deletions

View File

@@ -366,7 +366,7 @@ void AsyncWebServerRequest::requestAuthentication(const char *realm) const {
}
#endif
AsyncWebParameter *AsyncWebServerRequest::getParam(const std::string &name) {
AsyncWebParameter *AsyncWebServerRequest::getParam(const char *name) {
// Check cache first - only successful lookups are cached
for (auto *param : this->params_) {
if (param->name() == name) {
@@ -375,11 +375,11 @@ AsyncWebParameter *AsyncWebServerRequest::getParam(const std::string &name) {
}
// Look up value from query strings
optional<std::string> val = query_key_value(this->post_query_, name);
optional<std::string> val = query_key_value(this->post_query_.c_str(), this->post_query_.size(), name);
if (!val.has_value()) {
auto url_query = request_get_url_query(*this);
if (url_query.has_value()) {
val = query_key_value(url_query.value(), name);
val = query_key_value(url_query.value().c_str(), url_query.value().size(), name);
}
}