| 
    roar
    
   | 
 
#include <request.hpp>
Public Types | |
| using | LogsType = std::vector< VerboseLogEntry > | 
Public Member Functions | |
| Request () | |
| Request & | basicAuth (std::string const &name, std::string const &password) | 
| Sets a basic auth header.   | |
| Request & | bearerAuth (std::string const &bearerToken) | 
| Sets a bearer auth header.   | |
| Request & | acceptEncoding (std::string const &encoding) | 
| Sets the Accept-Encoding haeder.   | |
| Request & | followRedirects (bool doFollow) | 
| Automatically follow redirects?   | |
| Request & | maxRedirects (std::size_t maxRedirects) | 
| Sets the maximum number of redirects to follow.   | |
| Request & | autoReferer (bool doAutoRefer) | 
| When enabled libcurl will automatically set the Referer: header field in HTTP requests to the full URL where it follows a Location: redirect.   | |
| Request & | setHeaderFields (std::unordered_map< std::string, std::string > const &fields) | 
| Set the all header fields at one using the map.   | |
| Request & | setHeader (std::string const &key, std::string const &value) | 
| Set the speficied header field with value.   | |
| Request & | setHeader (boost::beast::http::field key, std::string const &value) | 
| Set the speficied header field with value.   | |
| Request & | verifyPeer (bool verify=true) | 
| Verify the peer in secure requests?   | |
| Request & | verifyHost (bool verify=true) | 
| Verify host in secure request?   | |
| Request & | expect100Continue () | 
| expect 100 continue?   | |
| Request & | connectTimeout (std::chrono::milliseconds timeout) | 
| Set a timeout for connects.   | |
| Request & | transferTimeout (std::chrono::milliseconds timeout) | 
| Set a timeout for transfers.   | |
| Request & | useSignals (bool useSignal) | 
| Shall curl use signals?   | |
| Request & | sink (std::function< void(char const *, std::size_t)> const &sinkFunction, std::function< void()> onComplete=[]() {}) | 
| A sink that is a simple function accepting the data.   | |
| Request & | sink (std::string &str) | 
| Installs a sink to a string.   | |
| Request & | sink (std::ostream &stream) | 
| Installs a sink to a stream.   | |
| Request & | sink (std::filesystem::path const &path) | 
| Installs a sink to a file.   | |
| Request & | sink (Sink &customSink) | 
| Installs a custom sink.   | |
| Request & | addLibcurlDefaultSink () | 
| Reenables outputting to stdout.   | |
| Request & | proxy (std::string const &url) | 
| Enables the use of a proxy.   | |
| Request & | tunnel (std::string const &url) | 
| Enables the use of a proxy tunnel (HTTPS proxy).   | |
| Request & | unixSocket (std::filesystem::path const &path) | 
| Use unix socket instead of a tcp socket.   | |
| Request & | contentType (std::string const &type) | 
| Sets the Content-Type header.   | |
| Request & | verbose (bool enable=true) | 
| Enables / Disables verbose logging.   | |
| Request & | verbose (LogsType &logs) | 
| Will enable verbose logging and log to log container.   | |
| Request & | onHeaderValue (std::function< void(std::string const &, std::string const &)> const &headerReceiver) | 
| The passed function is called when a header is received.   | |
| Request & | headerSink (std::unordered_map< std::string, std::string > &headers) | 
| Register a sink for header values, that takes all received headers.   | |
| template<typename SourceT , typename... Args> | |
| Request & | emplaceSource (Args &&... args) | 
| Inplace construct a source that is used for the sent body.   | |
| Request & | source (char const *str) | 
| Set the source from a c-string.   | |
| Request & | method (std::string const &method) | 
| Set the request method.   | |
| Request & | verb (std::string const &verb) | 
| Alias for method.   | |
| Request & | source (std::string str) | 
| Set the source from a string.   | |
| Request & | source (std::filesystem::path path) | 
| Set the source to be a file.   | |
| Response | get (std::string const &url) | 
| Finishes and performs the request as a get request.   | |
| Response | put (std::string const &url) | 
| Finishes and performs the request as a put request.   | |
| Response | post (std::string const &url) | 
| Finishes and performs the request as a post request.   | |
| Response | delete_ (std::string const &url) | 
| Finishes and performs the request as a delete request.   | |
| Response | options (std::string const &url) | 
| Finishes and performs the request as a options request.   | |
| Response | head (std::string const &url) | 
| Finishes and performs the request as a head request.   | |
| Response | patch (std::string const &url) | 
| Finishes and performs the request as a patch request.   | |
| Response | custom (std::string const &request, std::string const &url) | 
| For requests outside the common verbs. (Or for put requests without body).   | |
| Instance & | instance () | 
| Returns the underlying curl instance.   | |
| Request & | url (std::string const &url) | 
| The the url of the request.   | |
| Response | perform () | 
| Perform the request. Use this like verb("GET").url("bla.com").perform(). There are get,patch,put etc which combine these into one.   | |
Private Member Functions | |
| void | check (CURLcode code) | 
| void | setupSource (bool chunked) | 
| void | setupSinks () | 
Private Attributes | |
| Instance | instance_ | 
| std::function< void(char *, std::size_t)> | sink_ | 
| std::vector< std::pair< std::function< void(char *, std::size_t)>, std::function< void()> > > | sinks_ | 
| std::unique_ptr< Source > | source_ | 
| std::vector< std::function< void(std::string const &, std::string const &)> > | headerReceivers_ | 
| std::unordered_map< std::string, std::string > | headerFields_ | 
| using Roar::Curl::Request::LogsType = std::vector<VerboseLogEntry> | 
| Roar::Curl::Request::Request | ( | ) | 
| Request & Roar::Curl::Request::acceptEncoding | ( | std::string const & | encoding | ) | 
Sets the Accept-Encoding haeder.
| encoding | The accepted encoding. | 
| Request & Roar::Curl::Request::addLibcurlDefaultSink | ( | ) | 
Reenables outputting to stdout.
| Request & Roar::Curl::Request::autoReferer | ( | bool | doAutoRefer | ) | 
When enabled libcurl will automatically set the Referer: header field in HTTP requests to the full URL where it follows a Location: redirect.
| doAutoRefer | 
| Request & Roar::Curl::Request::basicAuth | ( | std::string const & | name, | 
| std::string const & | password | ||
| ) | 
Sets a basic auth header.
| name | User name | 
| password | User password. | 
| Request & Roar::Curl::Request::bearerAuth | ( | std::string const & | bearerToken | ) | 
Sets a bearer auth header.
| bearerToken | The token to send. | 
      
  | 
  private | 
| Request & Roar::Curl::Request::connectTimeout | ( | std::chrono::milliseconds | timeout | ) | 
Set a timeout for connects.
| timeout | The timeout in milliseconds. | 
| Request & Roar::Curl::Request::contentType | ( | std::string const & | type | ) | 
Sets the Content-Type header.
| type | The content type to set. | 
| Response Roar::Curl::Request::custom | ( | std::string const & | request, | 
| std::string const & | url | ||
| ) | 
For requests outside the common verbs. (Or for put requests without body).
| request | A custom request verb | 
| url | The target to send this request to. | 
| Response Roar::Curl::Request::delete_ | ( | std::string const & | url | ) | 
Finishes and performs the request as a delete request.
| url | The target to send this request to. | 
      
  | 
  inline | 
Inplace construct a source that is used for the sent body.
| SourceT | The source type (cannot be inferred). | 
| Args | Forwarded args to the source constructor. | 
| args | The forwarded args. | 
| Request & Roar::Curl::Request::expect100Continue | ( | ) | 
expect 100 continue?
| Request & Roar::Curl::Request::followRedirects | ( | bool | doFollow | ) | 
Automatically follow redirects?
| doFollow | Will follow redirects if true. | 
| Response Roar::Curl::Request::get | ( | std::string const & | url | ) | 
Finishes and performs the request as a get request.
| url | The target to send this request to. | 
| Response Roar::Curl::Request::head | ( | std::string const & | url | ) | 
Finishes and performs the request as a head request.
| url | The target to send this request to. | 
| Request & Roar::Curl::Request::headerSink | ( | std::unordered_map< std::string, std::string > & | headers | ) | 
Register a sink for header values, that takes all received headers.
| headers | A container that takes the header values. You must keep it alive. | 
| Instance & Roar::Curl::Request::instance | ( | ) | 
Returns the underlying curl instance.
| Request & Roar::Curl::Request::maxRedirects | ( | std::size_t | maxRedirects | ) | 
Sets the maximum number of redirects to follow.
| maxRedirects | The maximum number of redirects to follow. | 
| Request & Roar::Curl::Request::method | ( | std::string const & | method | ) | 
| Request & Roar::Curl::Request::onHeaderValue | ( | std::function< void(std::string const &, std::string const &)> const & | headerReceiver | ) | 
The passed function is called when a header is received.
| headerReceiver | A function taking header values. | 
| Response Roar::Curl::Request::options | ( | std::string const & | url | ) | 
Finishes and performs the request as a options request.
| url | The target to send this request to. | 
| Response Roar::Curl::Request::patch | ( | std::string const & | url | ) | 
Finishes and performs the request as a patch request.
| url | The target to send this request to. | 
| Response Roar::Curl::Request::perform | ( | ) | 
Perform the request. Use this like verb("GET").url("bla.com").perform(). There are get,patch,put etc which combine these into one.
| Response Roar::Curl::Request::post | ( | std::string const & | url | ) | 
Finishes and performs the request as a post request.
| url | The target to send this request to. | 
| Request & Roar::Curl::Request::proxy | ( | std::string const & | url | ) | 
Enables the use of a proxy.
| url | The url to the proxy. | 
| Response Roar::Curl::Request::put | ( | std::string const & | url | ) | 
Finishes and performs the request as a put request.
| url | The target to send this request to. | 
| Request & Roar::Curl::Request::setHeader | ( | boost::beast::http::field | key, | 
| std::string const & | value | ||
| ) | 
Set the speficied header field with value.
| key | The field. | 
| value | The value. | 
| Request & Roar::Curl::Request::setHeader | ( | std::string const & | key, | 
| std::string const & | value | ||
| ) | 
Set the speficied header field with value.
| key | The field. | 
| value | The value. | 
| Request & Roar::Curl::Request::setHeaderFields | ( | std::unordered_map< std::string, std::string > const & | fields | ) | 
Set the all header fields at one using the map.
| fields | A key/value object for header fields | 
      
  | 
  private | 
      
  | 
  private | 
Installs a custom sink.
| customSink | A sink deriving from Roar::Curl::Sink | 
| Request & Roar::Curl::Request::sink | ( | std::filesystem::path const & | path | ) | 
Installs a sink to a file.
This function does not check whether the path is writeable to.
| path | The path that should be written to. | 
      
  | 
  inline | 
A sink that is a simple function accepting the data.
| sinkFunction | This function will be repeatedly called with new data. | 
| Request & Roar::Curl::Request::sink | ( | std::ostream & | stream | ) | 
| Request & Roar::Curl::Request::sink | ( | std::string & | str | ) | 
Installs a sink to a string.
| str | The string that should be written to. | 
Set the source from a c-string.
| str | A string source. | 
| Request & Roar::Curl::Request::source | ( | std::filesystem::path | path | ) | 
| Request & Roar::Curl::Request::source | ( | std::string | str | ) | 
| Request & Roar::Curl::Request::transferTimeout | ( | std::chrono::milliseconds | timeout | ) | 
Set a timeout for transfers.
| timeout | The timeout in milliseconds. | 
| Request & Roar::Curl::Request::tunnel | ( | std::string const & | url | ) | 
Enables the use of a proxy tunnel (HTTPS proxy).
| url | The url to the proxy. | 
| Request & Roar::Curl::Request::unixSocket | ( | std::filesystem::path const & | path | ) | 
Use unix socket instead of a tcp socket.
| path | Path to the unix socket. | 
| Request & Roar::Curl::Request::url | ( | std::string const & | url | ) | 
The the url of the request.
| url | 
| Request & Roar::Curl::Request::useSignals | ( | bool | useSignal | ) | 
Shall curl use signals?
| useSignal | use signals yes/no? | 
| Request & Roar::Curl::Request::verb | ( | std::string const & | verb | ) | 
Alias for method.
| verb | 
| Request & Roar::Curl::Request::verbose | ( | bool | enable = true | ) | 
Enables / Disables verbose logging.
| enable | enable verbose logging yes/no | 
Will enable verbose logging and log to log container.
| logs | The log container to log to. You must keep it alive. | 
| Request & Roar::Curl::Request::verifyHost | ( | bool | verify = true | ) | 
Verify host in secure request?
| verify | verify yes/no? | 
| Request & Roar::Curl::Request::verifyPeer | ( | bool | verify = true | ) | 
Verify the peer in secure requests?
| verify | verify yes/no? | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private |