@@ -565,8 +565,10 @@ struct Request {
565565#endif
566566
567567 bool has_header (const std::string &key) const ;
568- std::string get_header_value (const std::string &key, size_t id = 0 ) const ;
569- uint64_t get_header_value_u64 (const std::string &key, size_t id = 0 ) const ;
568+ std::string get_header_value (const std::string &key, const char *def = " " ,
569+ size_t id = 0 ) const ;
570+ uint64_t get_header_value_u64 (const std::string &key, uint64_t def = 0 ,
571+ size_t id = 0 ) const ;
570572 size_t get_header_value_count (const std::string &key) const ;
571573 void set_header (const std::string &key, const std::string &val);
572574
@@ -597,8 +599,10 @@ struct Response {
597599 std::string location; // Redirect location
598600
599601 bool has_header (const std::string &key) const ;
600- std::string get_header_value (const std::string &key, size_t id = 0 ) const ;
601- uint64_t get_header_value_u64 (const std::string &key, size_t id = 0 ) const ;
602+ std::string get_header_value (const std::string &key, const char *def = " " ,
603+ size_t id = 0 ) const ;
604+ uint64_t get_header_value_u64 (const std::string &key, uint64_t def = 0 ,
605+ size_t id = 0 ) const ;
602606 size_t get_header_value_count (const std::string &key) const ;
603607 void set_header (const std::string &key, const std::string &val);
604608
@@ -1091,9 +1095,10 @@ class Result {
10911095 // Request Headers
10921096 bool has_request_header (const std::string &key) const ;
10931097 std::string get_request_header_value (const std::string &key,
1098+ const char *def = " " ,
10941099 size_t id = 0 ) const ;
10951100 uint64_t get_request_header_value_u64 (const std::string &key,
1096- size_t id = 0 ) const ;
1101+ uint64_t def = 0 , size_t id = 0 ) const ;
10971102 size_t get_request_header_value_count (const std::string &key) const ;
10981103
10991104private:
@@ -1914,8 +1919,8 @@ inline void duration_to_sec_and_usec(const T &duration, U callback) {
19141919}
19151920
19161921inline uint64_t get_header_value_u64 (const Headers &headers,
1917- const std::string &key, size_t id ,
1918- uint64_t def ) {
1922+ const std::string &key, uint64_t def ,
1923+ size_t id ) {
19191924 auto rng = headers.equal_range (key);
19201925 auto it = rng.first ;
19211926 std::advance (it, static_cast <ssize_t >(id));
@@ -1928,13 +1933,13 @@ inline uint64_t get_header_value_u64(const Headers &headers,
19281933} // namespace detail
19291934
19301935inline uint64_t Request::get_header_value_u64 (const std::string &key,
1931- size_t id) const {
1932- return detail::get_header_value_u64 (headers, key, id, 0 );
1936+ uint64_t def, size_t id) const {
1937+ return detail::get_header_value_u64 (headers, key, def, id );
19331938}
19341939
19351940inline uint64_t Response::get_header_value_u64 (const std::string &key,
1936- size_t id) const {
1937- return detail::get_header_value_u64 (headers, key, id, 0 );
1941+ uint64_t def, size_t id) const {
1942+ return detail::get_header_value_u64 (headers, key, def, id );
19381943}
19391944
19401945template <typename ... Args>
@@ -2119,8 +2124,9 @@ inline std::ostream &operator<<(std::ostream &os, const Error &obj) {
21192124}
21202125
21212126inline uint64_t Result::get_request_header_value_u64 (const std::string &key,
2127+ uint64_t def,
21222128 size_t id) const {
2123- return detail::get_header_value_u64 (request_headers_, key, id, 0 );
2129+ return detail::get_header_value_u64 (request_headers_, key, def, id );
21242130}
21252131
21262132template <class Rep , class Period >
@@ -2220,7 +2226,7 @@ socket_t create_client_socket(
22202226 time_t write_timeout_usec, const std::string &intf, Error &error);
22212227
22222228const char *get_header_value (const Headers &headers, const std::string &key,
2223- size_t id = 0 , const char *def = nullptr );
2229+ const char *def, size_t id );
22242230
22252231std::string params_to_query_str (const Params ¶ms);
22262232
@@ -3948,8 +3954,8 @@ inline bool has_header(const Headers &headers, const std::string &key) {
39483954}
39493955
39503956inline const char *get_header_value (const Headers &headers,
3951- const std::string &key, size_t id ,
3952- const char *def ) {
3957+ const std::string &key, const char *def ,
3958+ size_t id ) {
39533959 auto rng = headers.equal_range (key);
39543960 auto it = rng.first ;
39553961 std::advance (it, static_cast <ssize_t >(id));
@@ -4146,7 +4152,7 @@ inline bool read_content_chunked(Stream &strm, T &x,
41464152
41474153inline bool is_chunked_transfer_encoding (const Headers &headers) {
41484154 return compare_case_ignore (
4149- get_header_value (headers, " Transfer-Encoding" , 0 , " " ), " chunked" );
4155+ get_header_value (headers, " Transfer-Encoding" , " " , 0 ), " chunked" );
41504156}
41514157
41524158template <typename T, typename U>
@@ -5489,8 +5495,8 @@ inline bool Request::has_header(const std::string &key) const {
54895495}
54905496
54915497inline std::string Request::get_header_value (const std::string &key,
5492- size_t id) const {
5493- return detail::get_header_value (headers, key, id, " " );
5498+ const char *def, size_t id) const {
5499+ return detail::get_header_value (headers, key, def, id );
54945500}
54955501
54965502inline size_t Request::get_header_value_count (const std::string &key) const {
@@ -5554,8 +5560,9 @@ inline bool Response::has_header(const std::string &key) const {
55545560}
55555561
55565562inline std::string Response::get_header_value (const std::string &key,
5563+ const char *def,
55575564 size_t id) const {
5558- return detail::get_header_value (headers, key, id, " " );
5565+ return detail::get_header_value (headers, key, def, id );
55595566}
55605567
55615568inline size_t Response::get_header_value_count (const std::string &key) const {
@@ -5640,8 +5647,9 @@ inline bool Result::has_request_header(const std::string &key) const {
56405647}
56415648
56425649inline std::string Result::get_request_header_value (const std::string &key,
5650+ const char *def,
56435651 size_t id) const {
5644- return detail::get_header_value (request_headers_, key, id, " " );
5652+ return detail::get_header_value (request_headers_, key, def, id );
56455653}
56465654
56475655inline size_t
0 commit comments