|
kaycxx-http
HTTP client library
|
Synchronous HTTP client. More...
#include <kaycxx/http/client.hpp>
Public Member Functions | |
| client () | |
| Creates an HTTP client. | |
| client (request_options default_options) | |
| Creates an HTTP client with default request options. | |
| ~client () | |
| Destroys the HTTP client. | |
| client (const client &)=delete | |
| client & | operator= (const client &)=delete |
| client (client &&other) noexcept | |
| Moves an HTTP client. | |
| client & | operator= (client &&other) noexcept |
| Move-assigns an HTTP client. | |
| buffered_response | request (std::string_view method, std::string_view url, const request_options &options={}) |
| Sends an HTTP request and buffers the response body. | |
| buffered_response | request (std::string_view method, std::string_view url, request_body body, const request_options &options={}) |
| Sends an HTTP request with a body and buffers the response body. | |
| streamed_response | request (std::string_view method, std::string_view url, response_body output, const request_options &options={}) |
| Sends an HTTP request and streams the successful response body to an output stream. | |
| streamed_response | request (std::string_view method, std::string_view url, request_body body, response_body output, const request_options &options={}) |
| Sends an HTTP request with a body and streams the successful response body to an output stream. | |
| buffered_response | get (std::string_view url, const request_options &options={}) |
| Sends a GET request and buffers the response body. | |
| buffered_response | get (std::string_view url, request_body body, const request_options &options={}) |
| Sends a GET request with a body and buffers the response body. | |
| streamed_response | get (std::string_view url, response_body output, const request_options &options={}) |
| Sends a GET request and streams the successful response body to an output stream. | |
| streamed_response | get (std::string_view url, request_body body, response_body output, const request_options &options={}) |
| Sends a GET request with a body and streams the successful response body to an output stream. | |
| buffered_response | post (std::string_view url, const request_options &options={}) |
| Sends a POST request and buffers the response body. | |
| buffered_response | post (std::string_view url, request_body body, const request_options &options={}) |
| Sends a POST request with a body and buffers the response body. | |
| streamed_response | post (std::string_view url, response_body output, const request_options &options={}) |
| Sends a POST request and streams the successful response body to an output stream. | |
| streamed_response | post (std::string_view url, request_body body, response_body output, const request_options &options={}) |
| Sends a POST request with a body and streams the successful response body to an output stream. | |
| buffered_response | put (std::string_view url, const request_options &options={}) |
| Sends a PUT request and buffers the response body. | |
| buffered_response | put (std::string_view url, request_body body, const request_options &options={}) |
| Sends a PUT request with a body and buffers the response body. | |
| streamed_response | put (std::string_view url, response_body output, const request_options &options={}) |
| Sends a PUT request and streams the successful response body to an output stream. | |
| streamed_response | put (std::string_view url, request_body body, response_body output, const request_options &options={}) |
| Sends a PUT request with a body and streams the successful response body to an output stream. | |
| buffered_response | del (std::string_view url, const request_options &options={}) |
| Sends a DELETE request and buffers the response body. | |
| buffered_response | del (std::string_view url, request_body body, const request_options &options={}) |
| Sends a DELETE request with a body and buffers the response body. | |
| streamed_response | del (std::string_view url, response_body output, const request_options &options={}) |
| Sends a DELETE request and streams the successful response body to an output stream. | |
| streamed_response | del (std::string_view url, request_body body, response_body output, const request_options &options={}) |
| Sends a DELETE request with a body and streams the successful response body to an output stream. | |
Synchronous HTTP client.
A client retains its backend handle so sequential requests can reuse connections. A client instance must not be used concurrently from multiple threads. Starting another request reentrantly on the same instance throws error. A moved-from client can be destroyed or move-assigned; attempting to send a request with it throws error.
| kaycxx::http::client::client | ( | ) |
Creates an HTTP client.
| error | When libcurl cannot be initialized or its easy handle cannot be created. |
|
explicit |
Creates an HTTP client with default request options.
Request-specific options override these defaults. Headers are merged by ASCII case-insensitive name.
| default_options | Default options for requests sent by this client. |
| error | When libcurl cannot be initialized or its easy handle cannot be created. |
|
noexcept |
Moves an HTTP client.
| other | HTTP client to move from. |
|
nodiscard |
Sends a DELETE request and buffers the response body.
| url | Request URL. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
|
nodiscard |
Sends a DELETE request with a body and buffers the response body.
| url | Request URL. |
| body | Request body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
| nlohmann::json::type_error | When a JSON body cannot be serialized. |
|
nodiscard |
Sends a DELETE request with a body and streams the successful response body to an output stream.
| url | Request URL. |
| body | Request body. |
| output | Output stream receiving the successful response body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
| nlohmann::json::type_error | When a JSON body cannot be serialized. |
|
nodiscard |
Sends a DELETE request and streams the successful response body to an output stream.
| url | Request URL. |
| output | Output stream receiving the successful response body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
|
nodiscard |
Sends a GET request and buffers the response body.
| url | Request URL. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
|
nodiscard |
Sends a GET request with a body and buffers the response body.
| url | Request URL. |
| body | Request body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
| nlohmann::json::type_error | When a JSON body cannot be serialized. |
|
nodiscard |
Sends a GET request with a body and streams the successful response body to an output stream.
| url | Request URL. |
| body | Request body. |
| output | Output stream receiving the successful response body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
| nlohmann::json::type_error | When a JSON body cannot be serialized. |
|
nodiscard |
Sends a GET request and streams the successful response body to an output stream.
| url | Request URL. |
| output | Output stream receiving the successful response body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
Move-assigns an HTTP client.
| other | HTTP client to move from. |
|
nodiscard |
Sends a POST request and buffers the response body.
| url | Request URL. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
|
nodiscard |
Sends a POST request with a body and buffers the response body.
| url | Request URL. |
| body | Request body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
| nlohmann::json::type_error | When a JSON body cannot be serialized. |
|
nodiscard |
Sends a POST request with a body and streams the successful response body to an output stream.
| url | Request URL. |
| body | Request body. |
| output | Output stream receiving the successful response body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
| nlohmann::json::type_error | When a JSON body cannot be serialized. |
|
nodiscard |
Sends a POST request and streams the successful response body to an output stream.
| url | Request URL. |
| output | Output stream receiving the successful response body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
|
nodiscard |
Sends a PUT request and buffers the response body.
| url | Request URL. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
|
nodiscard |
Sends a PUT request with a body and buffers the response body.
| url | Request URL. |
| body | Request body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
| nlohmann::json::type_error | When a JSON body cannot be serialized. |
|
nodiscard |
Sends a PUT request with a body and streams the successful response body to an output stream.
| url | Request URL. |
| body | Request body. |
| output | Output stream receiving the successful response body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
| nlohmann::json::type_error | When a JSON body cannot be serialized. |
|
nodiscard |
Sends a PUT request and streams the successful response body to an output stream.
| url | Request URL. |
| output | Output stream receiving the successful response body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
|
nodiscard |
Sends an HTTP request and buffers the response body.
| method | HTTP request method. |
| url | Request URL. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
|
nodiscard |
Sends an HTTP request with a body and buffers the response body.
| method | HTTP request method. |
| url | Request URL. |
| body | Request body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
| nlohmann::json::type_error | When a JSON body cannot be serialized. |
|
nodiscard |
Sends an HTTP request with a body and streams the successful response body to an output stream.
Error response bodies are retained by the thrown response error and are not written to the output stream. A transport or output error can leave a partial successful response in the output stream.
| method | HTTP request method. |
| url | Request URL. |
| body | Request body. |
| output | Output stream receiving the successful response body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |
| nlohmann::json::type_error | When a JSON body cannot be serialized. |
|
nodiscard |
Sends an HTTP request and streams the successful response body to an output stream.
Error response bodies are retained by the thrown response error and are not written to the output stream. A transport or output error can leave a partial successful response in the output stream.
| method | HTTP request method. |
| url | Request URL. |
| output | Output stream receiving the successful response body. |
| options | Request options. |
| response_error | When the server returns a status code outside the range 200 to 299. |
| error | When the request cannot be configured or performed. |