34
34
#include < stddef.h>
35
35
#include < algorithm>
36
36
#include < iosfwd>
37
+ #include < limits>
37
38
#include < map>
38
39
#include < memory>
39
40
#include < string>
@@ -98,7 +99,7 @@ class http_request {
98
99
**/
99
100
const std::string get_path_piece (int index) const {
100
101
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 ) {
102
103
return post_path[index ];
103
104
}
104
105
return EMPTY;
@@ -258,11 +259,11 @@ class http_request {
258
259
/* *
259
260
* Default constructor of the class. It is a specific responsibility of apis to initialize this type of objects.
260
261
**/
261
- http_request () : cache(std::make_unique<http_request_data_cache>()) {}
262
+ http_request () = default ;
262
263
263
264
http_request (MHD_Connection* underlying_connection, unescaper_ptr unescaper):
264
265
underlying_connection (underlying_connection),
265
- unescaper (unescaper), cache(std::make_unique<http_request_data_cache>()) {}
266
+ unescaper (unescaper) {}
266
267
267
268
/* *
268
269
* Copy constructor. Deleted to make class move-only. The class is move-only for several reasons:
@@ -292,7 +293,7 @@ class http_request {
292
293
std::string method;
293
294
std::map<std::string, std::map<std::string, http::file_info>> files;
294
295
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( );
296
297
std::string version;
297
298
298
299
struct MHD_Connection * underlying_connection = nullptr ;
@@ -390,7 +391,7 @@ class http_request {
390
391
**/
391
392
void set_args (const std::map<std::string, std::string>& args) {
392
393
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));
394
395
}
395
396
}
396
397
@@ -410,7 +411,7 @@ class http_request {
410
411
std::string digested_user;
411
412
std::map<std::string, std::vector<std::string>, http::arg_comparator> unescaped_args;
412
413
};
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>() ;
414
415
// Populate the data cache unescaped_args
415
416
void populate_args () const ;
416
417
0 commit comments