kcurl v0.1.10
Basic C++23 wrapper over libcurl
 
Loading...
Searching...
No Matches
kcurl::http Namespace Reference

Classes

struct  Error
 Error of a fetch operation. More...
 
struct  Query
 
struct  Request
 Input parameter for fetch(). More...
 
struct  Response
 Successful response of a fetch operation. Response is a class template to enable user-side reuse for custom payloads (eg JSON). More...
 
struct  Response< void >
 
class  Status
 Wrapper over a response status code. More...
 

Typedefs

template<typename Type >
using Result = std::expected< Response< Type >, Error >
 Result of a fetch operation. Result is a class template to enable user-side reuse for custom Reponse payloads (eg JSON).
 

Enumerations

enum class  Verb : std::int8_t { Get , Post }
 

Functions

auto escape (std::string_view text) -> std::string
 Replace special characters to be URL-friendly.
 
auto unescape (std::string_view escaped) -> std::string
 Replace URL escapes with their source characters.
 
auto to_easy_request (Request request) -> easy::Request
 
auto perform (easy::Request const &request) -> Result< ByteArray >
 Perform easy::Request and interpret the easy::Result as an http::Result. This lower-level function is exposed primarily for users to customize some behavior after the conversion of an http::Request to an easy::Request in the process of fetching the Response. If that is not required, use fetch() directly.
 
auto fetch (Request request) -> Result< ByteArray >
 Primary http API.
 

Typedef Documentation

◆ Result

template<typename Type >
using kcurl::http::Result = typedef std::expected<Response<Type>, Error>

Result of a fetch operation. Result is a class template to enable user-side reuse for custom Reponse payloads (eg JSON).

Enumeration Type Documentation

◆ Verb

enum class kcurl::http::Verb : std::int8_t
strong
Enumerator
Get 
Post 

Function Documentation

◆ escape()

auto kcurl::http::escape ( std::string_view  text) -> std::string

Replace special characters to be URL-friendly.

Parameters
textInput (unescaped) text.
Returns
Escaped string.

◆ fetch()

auto kcurl::http::fetch ( Request  request) -> Result<ByteArray>
inline

Primary http API.

Parameters
requesthttp::Request to fetch.
Returns
http::Response as a ByteArray on success, else http::Error.

◆ perform()

auto kcurl::http::perform ( easy::Request const &  request) -> Result< ByteArray >

Perform easy::Request and interpret the easy::Result as an http::Result. This lower-level function is exposed primarily for users to customize some behavior after the conversion of an http::Request to an easy::Request in the process of fetching the Response. If that is not required, use fetch() directly.

Parameters
requesteasy::Request to perform.
Returns
http::Response as a ByteArray on success, else http::Error.

◆ to_easy_request()

auto kcurl::http::to_easy_request ( Request  request) -> easy::Request
Parameters
requesthttp Request to convert.
Returns
Corresponding easy::Request.

◆ unescape()

auto kcurl::http::unescape ( std::string_view  escaped) -> std::string

Replace URL escapes with their source characters.

Parameters
escapedEscaped string.
Returns
Unescaped string.