3434#include < stddef.h>
3535#include < algorithm>
3636#include < iosfwd>
37+ #include < limits>
3738#include < map>
3839#include < memory>
3940#include < string>
@@ -98,7 +99,7 @@ class http_request {
9899 **/
99100 const std::string get_path_piece (int index) const {
100101 std::vector<std::string> post_path = get_path_pieces ();
101- if (( static_cast <int >(( post_path.size ()) )) > index) {
102+ if (static_cast <int >(post_path.size ()) > index) {
102103 return post_path[index];
103104 }
104105 return EMPTY;
@@ -258,11 +259,11 @@ class http_request {
258259 /* *
259260 * Default constructor of the class. It is a specific responsibility of apis to initialize this type of objects.
260261 **/
261- http_request () : cache(std::make_unique<http_request_data_cache>()) {}
262+ http_request () = default ;
262263
263264 http_request (MHD_Connection* underlying_connection, unescaper_ptr unescaper):
264265 underlying_connection (underlying_connection),
265- unescaper (unescaper), cache(std::make_unique<http_request_data_cache>()) {}
266+ unescaper (unescaper) {}
266267
267268 /* *
268269 * Copy constructor. Deleted to make class move-only. The class is move-only for several reasons:
@@ -292,7 +293,7 @@ class http_request {
292293 std::string method;
293294 std::map<std::string, std::map<std::string, http::file_info>> files;
294295 std::string content = " " ;
295- size_t content_size_limit = static_cast <size_t >(- 1 );
296+ size_t content_size_limit = std::numeric_limits <size_t >::max( );
296297 std::string version;
297298
298299 struct MHD_Connection * underlying_connection = nullptr ;
@@ -390,7 +391,7 @@ class http_request {
390391 **/
391392 void set_args (const std::map<std::string, std::string>& args) {
392393 for (auto const & [key, value] : args) {
393- this -> cache ->unescaped_args [key].push_back (value.substr (0 , content_size_limit));
394+ cache->unescaped_args [key].push_back (value.substr (0 , content_size_limit));
394395 }
395396 }
396397
@@ -410,7 +411,7 @@ class http_request {
410411 std::string digested_user;
411412 std::map<std::string, std::vector<std::string>, http::arg_comparator> unescaped_args;
412413 };
413- std::unique_ptr<http_request_data_cache> cache;
414+ std::unique_ptr<http_request_data_cache> cache = std::make_unique<http_request_data_cache>() ;
414415 // Populate the data cache unescaped_args
415416 void populate_args () const ;
416417
0 commit comments