diff --git a/src/http/include/sourcemeta/hydra/http_request.h b/src/http/include/sourcemeta/hydra/http_request.h index 1411d8ef..b6b1e5ce 100644 --- a/src/http/include/sourcemeta/hydra/http_request.h +++ b/src/http/include/sourcemeta/hydra/http_request.h @@ -26,6 +26,8 @@ class SOURCEMETA_HYDRA_HTTP_EXPORT Request { auto capture(std::string header) -> void; auto capture(std::initializer_list headers) -> void; auto header(std::string_view key, std::string_view value) -> void; + auto header(std::string_view key, int value) -> void; + auto send() -> std::future; private: diff --git a/src/http/include/sourcemeta/hydra/http_stream.h b/src/http/include/sourcemeta/hydra/http_stream.h index 6eb1c554..94d96130 100644 --- a/src/http/include/sourcemeta/hydra/http_stream.h +++ b/src/http/include/sourcemeta/hydra/http_stream.h @@ -34,6 +34,7 @@ class SOURCEMETA_HYDRA_HTTP_EXPORT Stream { auto method(const Method method) noexcept -> void; auto header(std::string_view key, std::string_view value) -> void; + auto header(std::string_view key, int value) -> void; auto send() -> std::future; using DataCallback = diff --git a/src/http/request.cc b/src/http/request.cc index 6ee7838b..fb093c2d 100644 --- a/src/http/request.cc +++ b/src/http/request.cc @@ -35,6 +35,10 @@ auto Request::header(std::string_view key, std::string_view value) -> void { this->stream.header(key, value); } +auto Request::header(std::string_view key, int value) -> void { + this->stream.header(key, value); +} + auto Request::send() -> std::future { std::ostringstream output; this->stream.on_data( diff --git a/src/http/stream_curl.cc b/src/http/stream_curl.cc index 3db2d5c1..2cbe795e 100644 --- a/src/http/stream_curl.cc +++ b/src/http/stream_curl.cc @@ -205,6 +205,10 @@ auto Stream::header(std::string_view key, std::string_view value) -> void { curl_slist_append(this->internal->headers, result.c_str()); } +auto Stream::header(std::string_view key, int value) -> void { + this->header(key, std::to_string(value)); +} + auto Stream::send() -> std::future { switch (this->internal->method) { case Method::GET: