Skip to content

Commit c2c9656

Browse files
committed
For a POST parameter with a large value, libmicrohttpd will call webserver::post_iterator
multiple times with chunnks of post data and successibe offsets. Currently, set_arg will overwrites the value. So after all the successive post_iterator calls, the value will be set to the last chunk. This change fixes the set_arg() function(s).. by checking for existing value and appending to it than overwriting it.
1 parent 35dee0f commit c2c9656

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/httpserver/http_request.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,11 @@ class http_request
442442
**/
443443
void set_arg(const std::string& key, const std::string& value)
444444
{
445-
this->args[key] = value;
445+
if (this->args[key].empty()) {
446+
this->args[key] = value;
447+
} else {
448+
this->args[key].append(value);
449+
}
446450
}
447451
/**
448452
* Method used to set an argument value by key.
@@ -452,7 +456,11 @@ class http_request
452456
**/
453457
void set_arg(const char* key, const char* value, size_t size)
454458
{
455-
this->args[key] = std::string(value, size);
459+
if (this->args[key].empty()) {
460+
this->args[key] = std::string(value, size);
461+
} else {
462+
this->args[key].append(value, size);
463+
}
456464
}
457465
/**
458466
* Method used to set the content of the request

0 commit comments

Comments
 (0)