uvco 0.1
Loading...
Searching...
No Matches
uvco::Curl Class Reference

#include <curl.h>

Public Member Functions

 Curl (const Loop &loop)
 Curl (const Curl &)=delete
 Curl (Curl &&other)=delete
Curloperator= (const Curl &)=delete
Curloperator= (Curl &&other)=delete
 ~Curl ()
CurlRequest get (std::string url)
CurlRequest post (std::string url, std::span< const std::pair< std::string, std::string > > fields)
Promise< void > close ()
 Close the curl handle in order to free all associated resources.

Private Attributes

std::shared_ptr< UvCurlContext_context_

Detailed Description

A simple Curl client that can download files from the internet. Errors are currently handled for HTTP; other protocols have status codes that this class doesn't yet know about.

The download() method is a generator yielding received chunks of the remote resource. Make sure to always co_await the download generator until receiving a std::nullopt, and call close() after you're done with the Curl handle.

Downloads can be started and progressing concurrently.

Constructor & Destructor Documentation

◆ Curl() [1/3]

uvco::Curl::Curl ( const Loop & loop)
explicit
533 : context_{std::make_shared<UvCurlContext_>(loop)} {}
std::shared_ptr< UvCurlContext_ > context_
Definition curl.h:113

◆ Curl() [2/3]

uvco::Curl::Curl ( const Curl & )
delete

◆ Curl() [3/3]

uvco::Curl::Curl ( Curl && other)
delete

◆ ~Curl()

uvco::Curl::~Curl ( )
default

Member Function Documentation

◆ close()

Promise< void > uvco::Curl::close ( )

Close the curl handle in order to free all associated resources.

548{ return context_->close(); }

◆ get()

CurlRequest uvco::Curl::get ( std::string url)

Prepare a GET request.

Important: don't drop the returned object until the request has finished.

537 {
538 return CurlRequest{context_, CurlRequest::Method::GET, std::move(url)};
539}
@ GET
Definition curl.h:42

◆ operator=() [1/2]

Curl & uvco::Curl::operator= ( const Curl & )
delete

◆ operator=() [2/2]

Curl & uvco::Curl::operator= ( Curl && other)
delete

◆ post()

CurlRequest uvco::Curl::post ( std::string url,
std::span< const std::pair< std::string, std::string > > fields )

Prepare a POST request.

Important: don't drop the returned object until the request has finished.

543 {
544 return CurlRequest{context_, CurlRequest::Method::POST, std::move(url),
545 fields};
546}
@ POST
Definition curl.h:42

Member Data Documentation

◆ context_

std::shared_ptr<UvCurlContext_> uvco::Curl::context_
private

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