|
@@ -487,8 +487,7 @@ struct Request {
|
|
|
|
|
|
|
|
bool has_header(const std::string &key) const;
|
|
bool has_header(const std::string &key) const;
|
|
|
std::string get_header_value(const std::string &key, size_t id = 0) const;
|
|
std::string get_header_value(const std::string &key, size_t id = 0) const;
|
|
|
- template <typename T>
|
|
|
|
|
- T get_header_value(const std::string &key, size_t id = 0) const;
|
|
|
|
|
|
|
+ uint64_t get_header_value_u64(const std::string &key, size_t id = 0) const;
|
|
|
size_t get_header_value_count(const std::string &key) const;
|
|
size_t get_header_value_count(const std::string &key) const;
|
|
|
void set_header(const std::string &key, const std::string &val);
|
|
void set_header(const std::string &key, const std::string &val);
|
|
|
|
|
|
|
@@ -520,8 +519,7 @@ struct Response {
|
|
|
|
|
|
|
|
bool has_header(const std::string &key) const;
|
|
bool has_header(const std::string &key) const;
|
|
|
std::string get_header_value(const std::string &key, size_t id = 0) const;
|
|
std::string get_header_value(const std::string &key, size_t id = 0) const;
|
|
|
- template <typename T>
|
|
|
|
|
- T get_header_value(const std::string &key, size_t id = 0) const;
|
|
|
|
|
|
|
+ uint64_t get_header_value_u64(const std::string &key, size_t id = 0) const;
|
|
|
size_t get_header_value_count(const std::string &key) const;
|
|
size_t get_header_value_count(const std::string &key) const;
|
|
|
void set_header(const std::string &key, const std::string &val);
|
|
void set_header(const std::string &key, const std::string &val);
|
|
|
|
|
|
|
@@ -988,8 +986,8 @@ public:
|
|
|
bool has_request_header(const std::string &key) const;
|
|
bool has_request_header(const std::string &key) const;
|
|
|
std::string get_request_header_value(const std::string &key,
|
|
std::string get_request_header_value(const std::string &key,
|
|
|
size_t id = 0) const;
|
|
size_t id = 0) const;
|
|
|
- template <typename T>
|
|
|
|
|
- T get_request_header_value(const std::string &key, size_t id = 0) const;
|
|
|
|
|
|
|
+ uint64_t get_request_header_value_u64(const std::string &key,
|
|
|
|
|
+ size_t id = 0) const;
|
|
|
size_t get_request_header_value_count(const std::string &key) const;
|
|
size_t get_request_header_value_count(const std::string &key) const;
|
|
|
|
|
|
|
|
private:
|
|
private:
|
|
@@ -1710,15 +1708,9 @@ inline void duration_to_sec_and_usec(const T &duration, U callback) {
|
|
|
callback(static_cast<time_t>(sec), static_cast<time_t>(usec));
|
|
callback(static_cast<time_t>(sec), static_cast<time_t>(usec));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-inline T get_header_value(const Headers & /*headers*/,
|
|
|
|
|
- const std::string & /*key*/, size_t /*id*/ = 0,
|
|
|
|
|
- uint64_t /*def*/ = 0) {}
|
|
|
|
|
-
|
|
|
|
|
-template <>
|
|
|
|
|
-inline uint64_t get_header_value<uint64_t>(const Headers &headers,
|
|
|
|
|
- const std::string &key, size_t id,
|
|
|
|
|
- uint64_t def) {
|
|
|
|
|
|
|
+inline uint64_t get_header_value_u64(const Headers &headers,
|
|
|
|
|
+ const std::string &key, size_t id,
|
|
|
|
|
+ uint64_t def) {
|
|
|
auto rng = headers.equal_range(key);
|
|
auto rng = headers.equal_range(key);
|
|
|
auto it = rng.first;
|
|
auto it = rng.first;
|
|
|
std::advance(it, static_cast<ssize_t>(id));
|
|
std::advance(it, static_cast<ssize_t>(id));
|
|
@@ -1730,14 +1722,14 @@ inline uint64_t get_header_value<uint64_t>(const Headers &headers,
|
|
|
|
|
|
|
|
} // namespace detail
|
|
} // namespace detail
|
|
|
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-inline T Request::get_header_value(const std::string &key, size_t id) const {
|
|
|
|
|
- return detail::get_header_value<T>(headers, key, id, 0);
|
|
|
|
|
|
|
+inline uint64_t Request::get_header_value_u64(const std::string &key,
|
|
|
|
|
+ size_t id) const {
|
|
|
|
|
+ return detail::get_header_value_u64(headers, key, id, 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-inline T Response::get_header_value(const std::string &key, size_t id) const {
|
|
|
|
|
- return detail::get_header_value<T>(headers, key, id, 0);
|
|
|
|
|
|
|
+inline uint64_t Response::get_header_value_u64(const std::string &key,
|
|
|
|
|
+ size_t id) const {
|
|
|
|
|
+ return detail::get_header_value_u64(headers, key, id, 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template <typename... Args>
|
|
template <typename... Args>
|
|
@@ -1906,10 +1898,9 @@ inline std::ostream &operator<<(std::ostream &os, const Error &obj) {
|
|
|
return os;
|
|
return os;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-inline T Result::get_request_header_value(const std::string &key,
|
|
|
|
|
- size_t id) const {
|
|
|
|
|
- return detail::get_header_value<T>(request_headers_, key, id, 0);
|
|
|
|
|
|
|
+inline uint64_t Result::get_request_header_value_u64(const std::string &key,
|
|
|
|
|
+ size_t id) const {
|
|
|
|
|
+ return detail::get_header_value_u64(request_headers_, key, id, 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template <class Rep, class Period>
|
|
template <class Rep, class Period>
|
|
@@ -3894,7 +3885,7 @@ bool read_content(Stream &strm, T &x, size_t payload_max_length, int &status,
|
|
|
} else if (!has_header(x.headers, "Content-Length")) {
|
|
} else if (!has_header(x.headers, "Content-Length")) {
|
|
|
ret = read_content_without_length(strm, out);
|
|
ret = read_content_without_length(strm, out);
|
|
|
} else {
|
|
} else {
|
|
|
- auto len = get_header_value<uint64_t>(x.headers, "Content-Length");
|
|
|
|
|
|
|
+ auto len = get_header_value_u64(x.headers, "Content-Length", 0, 0);
|
|
|
if (len > payload_max_length) {
|
|
if (len > payload_max_length) {
|
|
|
exceed_payload_max_length = true;
|
|
exceed_payload_max_length = true;
|
|
|
skip_content_with_length(strm, len);
|
|
skip_content_with_length(strm, len);
|