66
77#include < functional>
88#include < map>
9+ #include < span>
910#include < string>
1011#include < string_view>
1112
12- #include " span.h"
13-
1413namespace OpenShock ::HTTP {
1514 enum class RequestResult : uint8_t {
1615 InternalError, // Internal error
@@ -31,7 +30,11 @@ namespace OpenShock::HTTP {
3130 T data;
3231
3332 Response (RequestResult r, int c, T d)
34- : result (r), code (c), data (std::move (d)) {}
33+ : result (r)
34+ , code (c)
35+ , data (std::move (d))
36+ {
37+ }
3538
3639 inline const char * ResultToString () const
3740 {
@@ -65,11 +68,11 @@ namespace OpenShock::HTTP {
6568 using GotContentLengthCallback = std::function<bool (int contentLength)>;
6669 using DownloadCallback = std::function<bool (std::size_t offset, const uint8_t * data, std::size_t len)>;
6770
68- Response<std::size_t > Download (std::string_view url, const std::map<String, String>& headers, GotContentLengthCallback contentLengthCallback, DownloadCallback downloadCallback, tcb ::span<const uint16_t > acceptedCodes, uint32_t timeoutMs = 10'000 );
69- Response<std::string> GetString (std::string_view url, const std::map<String, String>& headers, tcb ::span<const uint16_t > acceptedCodes, uint32_t timeoutMs = 10'000 );
71+ Response<std::size_t > Download (std::string_view url, const std::map<String, String>& headers, GotContentLengthCallback contentLengthCallback, DownloadCallback downloadCallback, std ::span<const uint16_t > acceptedCodes, uint32_t timeoutMs = 10'000 );
72+ Response<std::string> GetString (std::string_view url, const std::map<String, String>& headers, std ::span<const uint16_t > acceptedCodes, uint32_t timeoutMs = 10'000 );
7073
7174 template <typename T>
72- Response<T> GetJSON (std::string_view url, const std::map<String, String>& headers, JsonParser<T> jsonParser, tcb ::span<const uint16_t > acceptedCodes, uint32_t timeoutMs = 10'000 )
75+ Response<T> GetJSON (std::string_view url, const std::map<String, String>& headers, JsonParser<T> jsonParser, std ::span<const uint16_t > acceptedCodes, uint32_t timeoutMs = 10'000 )
7376 {
7477 auto response = GetString (url, headers, acceptedCodes, timeoutMs);
7578 if (response.result != RequestResult::Success) {
0 commit comments