Hydra 0.0.1
A convenience networking library for modern C++
 
Loading...
Searching...
No Matches
http_request.h
1#ifndef SOURCEMETA_HYDRA_HTTP_REQUEST_H
2#define SOURCEMETA_HYDRA_HTTP_REQUEST_H
3
4#ifndef SOURCEMETA_HYDRA_HTTP_EXPORT
5#include <sourcemeta/hydra/http_export.h>
6#endif
7
8#include <sourcemeta/hydra/http_response.h>
9#include <sourcemeta/hydra/http_stream.h>
10
11#include <initializer_list> // std::initializer_list
12#include <istream> // std::istream
13#include <set> // std::set
14#include <string> // std::string
15#include <string_view> // std::string_view
16
17namespace sourcemeta::hydra::http {
18
21class SOURCEMETA_HYDRA_HTTP_EXPORT ClientRequest {
22public:
34 ClientRequest(std::string url);
35
51 auto method(const Method method) noexcept -> void;
52
64 auto method() const noexcept -> Method;
65
81 auto capture(std::string header) -> void;
82
98 auto capture(std::initializer_list<std::string> headers) -> void;
99
113 auto capture() -> void;
114
126 auto header(std::string_view key, std::string_view value) -> void;
127
139 auto header(std::string_view key, int value) -> void;
140
150 auto url() const -> std::string_view;
151
163 auto send() -> ClientResponse;
164
179 auto send(std::istream &body) -> ClientResponse;
180
181private:
182 ClientStream stream;
183// Exporting symbols that depends on the standard C++ library is considered
184// safe.
185// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
186#if defined(_MSC_VER)
187#pragma warning(disable : 4251)
188#endif
189 std::set<std::string> capture_;
190#if defined(_MSC_VER)
191#pragma warning(default : 4251)
192#endif
193 bool capture_all_{false};
194};
195
196} // namespace sourcemeta::hydra::http
197
198#endif
Definition http_request.h:21
auto method() const noexcept -> Method
auto method(const Method method) noexcept -> void
Definition http_response.h:20
Definition http_stream.h:20
Method
Definition http_method.h:8