kcurl v0.1.10
Basic C++23 wrapper over libcurl
 
Loading...
Searching...
No Matches
easy.hpp
Go to the documentation of this file.
1#pragma once
3#include "kcurl/curl_code.hpp"
4#include <cstdint>
5#include <expected>
6#include <string>
7
8namespace kcurl::easy {
10struct Error {
14 std::string text{};
15};
16
18struct Request {
19 enum Flag : std::uint8_t {
20 None = 0,
23 };
24
26 std::string url{};
27
29 std::string user_agent{};
31 std::string post_fields{};
33 std::vector<std::string> headers{};
36};
37
39struct Response {
41 std::int64_t code{};
44};
45
47using Result = std::expected<Response, Error>;
48
52[[nodiscard]] auto perform(Request const& request) -> Result;
53} // namespace kcurl::easy
Definition easy.hpp:8
auto perform(Request const &request) -> Result
Primary easy API.
std::expected< Response, Error > Result
Result of a fetch operation.
Definition easy.hpp:47
CurlCode
Definition curl_code.hpp:6
Definition byte_array.hpp:7
Error of a perform operation.
Definition easy.hpp:10
CurlCode code
Code returned by libcurl.
Definition easy.hpp:12
std::string text
Error text.
Definition easy.hpp:14
Input parameter for perform().
Definition easy.hpp:18
Flag flags
Request flags.
Definition easy.hpp:35
Flag
Definition easy.hpp:19
@ SkipPeerVerification
Definition easy.hpp:21
@ None
Definition easy.hpp:20
@ SkipHostnameVerification
Definition easy.hpp:22
std::string url
URL to fetch. Must be a valid URL.
Definition easy.hpp:26
std::vector< std::string > headers
List of HTTP headers, if any.
Definition easy.hpp:33
std::string post_fields
Concatenated string of post fields, if any.
Definition easy.hpp:31
std::string user_agent
User agent to use, if any.
Definition easy.hpp:29
Successful response of a perform operation.
Definition easy.hpp:39
ByteArray bytes
Response payload as bytes.
Definition easy.hpp:43
std::int64_t code
Response code.
Definition easy.hpp:41