@@ -361,7 +361,7 @@ class http_request
361361 * Default constructor of the class. It is a specific responsibility of apis to initialize this type of objects.
362362 **/
363363 http_request ():
364- content (" " )
364+ content (" " ), content_size_limit( static_cast < size_t >(- 1 ))
365365 {
366366 }
367367 /* *
@@ -381,6 +381,7 @@ class http_request
381381 args (b.args),
382382 querystring (b.querystring),
383383 content (b.content),
384+ content_size_limit (b.content_size_limit),
384385 version (b.version),
385386 requestor (b.requestor),
386387 underlying_connection (b.underlying_connection)
@@ -398,6 +399,7 @@ class http_request
398399 std::map<std::string, std::string, http::arg_comparator> args;
399400 std::string querystring;
400401 std::string content;
402+ size_t content_size_limit;
401403 std::string version;
402404 std::string requestor;
403405
@@ -442,7 +444,7 @@ class http_request
442444 **/
443445 void set_arg (const std::string& key, const std::string& value)
444446 {
445- this ->args [key] = value;
447+ this ->args [key] = value. substr ( 0 ,content_size_limit) ;
446448 }
447449 /* *
448450 * Method used to set an argument value by key.
@@ -452,29 +454,37 @@ class http_request
452454 **/
453455 void set_arg (const char * key, const char * value, size_t size)
454456 {
455- this ->args [key] = std::string (value, size);
457+ this ->args [key] = std::string (value,
458+ std::min (size, content_size_limit));
456459 }
457460 /* *
458461 * Method used to set the content of the request
459462 * @param content The content to set.
460463 **/
461464 void set_content (const std::string& content)
462465 {
463- this ->content = content;
466+ this ->content = content.substr (0 ,content_size_limit);
467+ }
468+ /* *
469+ * Method used to set the maximum size of the content
470+ * @param content_size_limit The limit on the maximum size of the content and arg's.
471+ **/
472+ void set_content_size_limit (size_t content_size_limit)
473+ {
474+ this ->content_size_limit = content_size_limit;
464475 }
465476 /* *
466477 * Method used to append content to the request preserving the previous inserted content
467478 * @param content The content to append.
468479 * @param size The size of the data to append.
469480 **/
470- void grow_content (const char * content, size_t size,
471- size_t content_size_limit)
481+ void grow_content (const char * content, size_t size)
472482 {
473483 this ->content .append (content, size);
474484 if (this ->content .size () > content_size_limit)
475- {
485+ {
476486 this ->content .resize (content_size_limit);
477- }
487+ }
478488 }
479489 /* *
480490 * Method used to set the path requested.
@@ -565,7 +575,7 @@ class http_request
565575 {
566576 std::map<std::string, std::string>::const_iterator it;
567577 for (it = args.begin (); it != args.end (); ++it)
568- this ->args [it->first ] = it->second ;
578+ this ->args [it->first ] = it->second . substr ( 0 ,content_size_limit) ;
569579 }
570580 /* *
571581 * Method used to set the username of the request.
0 commit comments