Thoth
A functional, expressive, asynchronous C++26 webdev library
Loading...
Searching...
No Matches
Request.hpp
Go to the documentation of this file.
1#pragma once
2#include <Hermes/Socket/ClientSocket.hpp>
3
7
9
10namespace Thoth::Http {
11 enum class VersionEnum : uint8_t {
12 HTTP1_0,
13 HTTP1_1,
14 HTTP2,
15 HTTP3,
16 };
17
19 std::string_view VersionToString(VersionEnum version);
20
21
22
23 template<class T>
24 concept SizedRequestBodyConcept = std::ranges::input_range<T>
25 && std::ranges::sized_range<T>
26 && (
27 std::same_as<std::ranges::range_value_t<T>, char> ||
28 std::same_as<std::ranges::range_value_t<T>, unsigned char> ||
29 std::same_as<std::ranges::range_value_t<T>, std::byte>
30 );
31
32 template<class T>
34
35 template<class T>
37
38
39
40 template<MethodConcept Method = GetMethod, RequestBodyConcept Body = std::string>
41 struct Request {
42 using MethodType = Method;
43
45 Body body;
48
50 template<class T = string_view>
51 requires Hermes::ByteLike<std::ranges::range_value_t<T>>
52 || (std::same_as<Body, std::string> && requires (T t) { { std::format("{}", t) }; })
53 static std::expected<Request, RequestError> FromUrl(
55 };
56
59
62}
63
64
65#include <Thoth/Http/Request/Request.tpp>
Definition Request.hpp:36
Definition Request.hpp:24
Definition Client.hpp:12
std::string_view VersionToString(VersionEnum version)
Exactly what you think it is.
VersionEnum
Definition Request.hpp:11
std::string_view string_view
Definition Url.hpp:7
This class stores the headers from HTTP.
Definition Headers.hpp:29
static Headers DefaultHeaders()
Represents the collection of HTTP headers associated with a request. Based on modern HTTP RFCs and in...
Definition RequestHeaders.hpp:12
Definition Request.hpp:41
static std::expected< Request, RequestError > FromUrl(string_view url, T &&body={}, Headers headers=Headers::DefaultHeaders())
Try parse to a URL before construct the Request.
VersionEnum version
Definition Request.hpp:46
Method MethodType
Definition Request.hpp:42
Url url
Definition Request.hpp:44
RequestHeaders headers
Definition Request.hpp:47
Body body
Definition Request.hpp:45
Definition Url.hpp:10