12#include <unordered_map>
27 std::map<std::string, std::string>
headers;
38 std::optional<std::string>
header(std::string_view name)
const;
66 Response send(std::chrono::milliseconds timeout = std::chrono::seconds(5));
75 std::vector<std::pair<std::string, std::string>>
headers_;
77 std::unordered_map<std::string, std::string>
cookies_;
a class to store JSON values
Definition json.hpp:19401
Manages routing of HTTP requests to their appropriate handlers.
Definition Router.hpp:46
The main application class for the Orbit Framework.
Definition App.hpp:36
Calls an application's routes in-process, without listen() or sockets: for fast, port-free tests.
Definition Client.hpp:105
RequestBuilder options(std::string target)
Definition Client.hpp:118
Client(server::App &app, size_t worker_threads=2)
RequestBuilder put(std::string target)
Definition Client.hpp:115
Client(const routing::Router &router, size_t worker_threads=2)
RequestBuilder head(std::string target)
Definition Client.hpp:119
std::map< std::string, std::string > cookies_
Definition Client.hpp:131
Client & operator=(const Client &)=delete
RequestBuilder patch(std::string target)
Definition Client.hpp:116
RequestBuilder get(std::string target)
Definition Client.hpp:113
Client(const Client &)=delete
const routing::Router & router_
Definition Client.hpp:129
RequestBuilder request(http::HttpMethod method, std::string target)
Definition Client.hpp:120
RequestBuilder post(std::string target)
Definition Client.hpp:114
std::map< std::string, std::string > & cookies()
The cookie jar: name -> value, updated from every response.
Definition Client.hpp:123
RequestBuilder del(std::string target)
std::unique_ptr< Runtime > runtime_
Definition Client.hpp:130
One request, built fluently and run with send().
Definition Client.hpp:48
RequestBuilder & body(std::string body, std::string content_type="text/plain")
The body and, unless content_type is empty, its Content-Type.
std::string body_
Definition Client.hpp:76
RequestBuilder & client_ip(std::string ip)
The client address the application sees (default 127.0.0.1).
std::unordered_map< std::string, std::string > cookies_
Definition Client.hpp:77
Client & client_
Definition Client.hpp:72
RequestBuilder(Client &client, http::HttpMethod method, std::string target)
RequestBuilder & header(std::string name, std::string value)
RequestBuilder & json(const nlohmann::json &value)
A JSON body (Content-Type: application/json).
std::string target_
Definition Client.hpp:74
Response send(std::chrono::milliseconds timeout=std::chrono::seconds(5))
Runs the request through the application and waits until the response is complete,...
http::HttpMethod method_
Definition Client.hpp:73
std::string client_ip_
Definition Client.hpp:78
std::vector< std::pair< std::string, std::string > > headers_
Definition Client.hpp:75
RequestBuilder & cookie(std::string name, std::string value)
A cookie for this request only, on top of the client's cookie jar.
HttpMethod
Represents standard HTTP methods.
Definition HttpRequest.hpp:28
Definition legacy_namespaces.hpp:24
Definition Http2Session.hpp:18
server::App App
Definition orbit.hpp:91
What the application answered, as a test sees it.
Definition Client.hpp:24
std::optional< std::string > header(std::string_view name) const
A header, by case-insensitive name.
std::string body
The whole body: the response body, or every chunk of a streamed one.
Definition Client.hpp:29
bool complete
Definition Client.hpp:35
std::vector< std::string > chunks
A streamed response's chunks (write_chunk() and SSE events), in order.
Definition Client.hpp:31
int status
Definition Client.hpp:25
std::map< std::string, std::string > headers
Header names as the application set them; look them up with header().
Definition Client.hpp:27
std::vector< http::Cookie > cookies
Definition Client.hpp:32
nlohmann::json json() const
The body parsed as JSON (null if it is not JSON).