kaycxx-http
HTTP client library
Loading...
Searching...
No Matches
kaycxx::http::request_body Class Reference

Non-owning HTTP request body descriptor. More...

#include <kaycxx/http/request_body.hpp>

Public Member Functions

 request_body () noexcept
 Creates an empty request body.
 request_body (std::string_view body) noexcept
 Creates a text request body.
 request_body (const std::string &body) noexcept
 Creates a text request body from a string.
 request_body (const char *body)
 Creates a text request body from a null-terminated string.
 request_body (std::span< const std::byte > body) noexcept
 Creates a binary request body.
 request_body (std::span< std::byte > body) noexcept
 Creates a binary request body from a mutable byte span.
 request_body (const std::vector< std::byte > &body) noexcept
 Creates a binary request body from a byte vector.
 request_body (std::istream &input) noexcept
 Creates a streamed request body with an unknown size.
 request_body (sized_istream input) noexcept
 Creates a streamed request body with a known size.
 request_body (const nlohmann::json &body) noexcept
 Creates a JSON request body.
 request_body (const url_encoded_form &body) noexcept
 Creates a URL-encoded form request body.
 request_body (const multipart_form &body) noexcept
 Creates a multipart form request body.

Friends

class client

Detailed Description

Non-owning HTTP request body descriptor.

Referenced strings, byte containers, streams, JSON values and forms must remain valid until the synchronous request returns. An input stream is consumed from its current position. When it is seekable, redirects and authentication retries can rewind it to that initial position.

Constructor & Destructor Documentation

◆ request_body() [1/11]

kaycxx::http::request_body::request_body ( std::string_view body)
noexcept

Creates a text request body.

Parameters
bodyText to send.

◆ request_body() [2/11]

kaycxx::http::request_body::request_body ( const std::string & body)
noexcept

Creates a text request body from a string.

Parameters
bodyString to send.

◆ request_body() [3/11]

kaycxx::http::request_body::request_body ( const char * body)

Creates a text request body from a null-terminated string.

Parameters
bodyNull-terminated string to send.
Exceptions
std::invalid_argumentWhen body is null.

◆ request_body() [4/11]

kaycxx::http::request_body::request_body ( std::span< const std::byte > body)
noexcept

Creates a binary request body.

Parameters
bodyBytes to send.

◆ request_body() [5/11]

kaycxx::http::request_body::request_body ( std::span< std::byte > body)
noexcept

Creates a binary request body from a mutable byte span.

Parameters
bodyBytes to send.

◆ request_body() [6/11]

kaycxx::http::request_body::request_body ( const std::vector< std::byte > & body)
noexcept

Creates a binary request body from a byte vector.

Parameters
bodyByte vector to send.

◆ request_body() [7/11]

kaycxx::http::request_body::request_body ( std::istream & input)
noexcept

Creates a streamed request body with an unknown size.

Parameters
inputInput stream providing the request body.

◆ request_body() [8/11]

kaycxx::http::request_body::request_body ( sized_istream input)
noexcept

Creates a streamed request body with a known size.

Parameters
inputSized input stream providing the request body.

◆ request_body() [9/11]

kaycxx::http::request_body::request_body ( const nlohmann::json & body)
noexcept

Creates a JSON request body.

Parameters
bodyJSON value to serialize and send.

◆ request_body() [10/11]

kaycxx::http::request_body::request_body ( const url_encoded_form & body)
noexcept

Creates a URL-encoded form request body.

Parameters
bodyURL-encoded form to serialize and send.

◆ request_body() [11/11]

kaycxx::http::request_body::request_body ( const multipart_form & body)
noexcept

Creates a multipart form request body.

Parameters
bodyMultipart form to send.

The documentation for this class was generated from the following file: