Skip to content

Commit 38f9610

Browse files
committed
Take integer request header values
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 14889ae commit 38f9610

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

src/http/include/sourcemeta/hydra/http_request.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class SOURCEMETA_HYDRA_HTTP_EXPORT Request {
2626
auto capture(std::string header) -> void;
2727
auto capture(std::initializer_list<std::string> headers) -> void;
2828
auto header(std::string_view key, std::string_view value) -> void;
29+
auto header(std::string_view key, int value) -> void;
30+
2931
auto send() -> std::future<Response>;
3032

3133
private:

src/http/include/sourcemeta/hydra/http_stream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class SOURCEMETA_HYDRA_HTTP_EXPORT Stream {
3434

3535
auto method(const Method method) noexcept -> void;
3636
auto header(std::string_view key, std::string_view value) -> void;
37+
auto header(std::string_view key, int value) -> void;
3738
auto send() -> std::future<Status>;
3839

3940
using DataCallback =

src/http/request.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ auto Request::header(std::string_view key, std::string_view value) -> void {
3535
this->stream.header(key, value);
3636
}
3737

38+
auto Request::header(std::string_view key, int value) -> void {
39+
this->stream.header(key, value);
40+
}
41+
3842
auto Request::send() -> std::future<Response> {
3943
std::ostringstream output;
4044
this->stream.on_data(

src/http/stream_curl.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ auto Stream::header(std::string_view key, std::string_view value) -> void {
205205
curl_slist_append(this->internal->headers, result.c_str());
206206
}
207207

208+
auto Stream::header(std::string_view key, int value) -> void {
209+
this->header(key, std::to_string(value));
210+
}
211+
208212
auto Stream::send() -> std::future<Status> {
209213
switch (this->internal->method) {
210214
case Method::GET:

0 commit comments

Comments
 (0)