cpp-ipfs-http-client
IPFS C++ client library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ipfs::http::TransportCurl Class Reference

Convenience class for talking basic HTTP, implemented using CURL. More...

#include <ipfs/http/transport-curl.h>

Inheritance diagram for ipfs::http::TransportCurl:
ipfs::http::Transport

Public Member Functions

 TransportCurl (bool curlVerbose)
 Constructor.
 
 TransportCurl (const TransportCurl &other)
 Copy Constructor.
 
 TransportCurl (TransportCurl &&other) noexcept
 Move-constructor.
 
TransportCurloperator= (const TransportCurl &)
 Copy assignment operator.
 
TransportCurloperator= (TransportCurl &&) noexcept
 Move assignment operator.
 
std::unique_ptr< TransportClone () const override
 Return a deep copy of this object.
 
 ~TransportCurl ()
 Destructor.
 
void Fetch (const std::string &url, const std::vector< FileUpload > &files, std::iostream *response) override
 Fetch the contents of a given URL.
 
void StopFetch () override
 Stop the fetch method abruptly, useful whenever the Fetch method is used within a thead, but you want to stop the thread (without using pthread_cancel).
 
void ResetFetch () override
 Reset the internal state, after StopFetch() is called.
 
void UrlEncode (const std::string &raw, std::string *encoded) override
 URL encode a string.
 
void Test ()
 Test the internals that are hard to execute from the public API, like error handling of some exceptional cases.
 
- Public Member Functions inherited from ipfs::http::Transport
virtual std::unique_ptr< TransportClone () const =0
 Return a deep copy of this object.
 
virtual ~Transport ()
 Destructor.
 
virtual void Fetch (const std::string &url, const std::vector< FileUpload > &files, std::iostream *response)=0
 Fetch the contents of a given URL.
 
virtual void StopFetch ()=0
 Stop the Fetch method abruptly.
 
virtual void ResetFetch ()=0
 Reset the internal state, after StopFetch() is called.
 
virtual void UrlEncode (const std::string &raw, std::string *encoded)=0
 URL encode a string.
 

Detailed Description

Convenience class for talking basic HTTP, implemented using CURL.

Constructor & Destructor Documentation

◆ TransportCurl() [1/3]

ipfs::http::TransportCurl::TransportCurl ( bool  curlVerbose)

Constructor.

Parameters
[in]curlVerboseEnable cURL verbose mode, useful for debugging.

◆ TransportCurl() [2/3]

ipfs::http::TransportCurl::TransportCurl ( const TransportCurl other)

Copy Constructor.

Parameters
[in]otherOther TransportCurl object to be copied.

◆ TransportCurl() [3/3]

ipfs::http::TransportCurl::TransportCurl ( TransportCurl &&  other)
noexcept

Move-constructor.

Parameters
[in]otherTransportCurl object to be moved.

Member Function Documentation

◆ Clone()

std::unique_ptr< Transport > ipfs::http::TransportCurl::Clone ( ) const
overridevirtual

Return a deep copy of this object.

Returns
Unique pointer of the Transport object.

Implements ipfs::http::Transport.

◆ Fetch()

void ipfs::http::TransportCurl::Fetch ( const std::string &  url,
const std::vector< FileUpload > &  files,
std::iostream *  response 
)
overridevirtual

Fetch the contents of a given URL.

If any files are provided in files, they are submitted using "Content-Type: multipart/form-data".

Fetch method is thread-safe. Therefor, can be used within a thread.

Exceptions
std::exceptionif any error occurs including erroneous HTTP status code
Parameters
[in]urlURL to get.
[in]filesList of files to upload.
[out]responseOutput to save the response body to.

Implements ipfs::http::Transport.

◆ operator=() [1/2]

TransportCurl & ipfs::http::TransportCurl::operator= ( const TransportCurl other)

Copy assignment operator.

Returns
*this
Parameters
[in]otherOther TransportCurl object to be copied.

◆ operator=() [2/2]

TransportCurl & ipfs::http::TransportCurl::operator= ( TransportCurl &&  other)
noexcept

Move assignment operator.

Returns
*this
Parameters
[in,out]otherOther TransportCurl object to be moved.

◆ ResetFetch()

void ipfs::http::TransportCurl::ResetFetch ( )
overridevirtual

Reset the internal state, after StopFetch() is called.

This method needs to be called once the thread is fully finished. Ideally after client.abort() and thread.join() methods.

Call this method out-side of the running thread, eg. the main thread.

Implements ipfs::http::Transport.

◆ StopFetch()

void ipfs::http::TransportCurl::StopFetch ( )
overridevirtual

Stop the fetch method abruptly, useful whenever the Fetch method is used within a thead, but you want to stop the thread (without using pthread_cancel).

Call this method out-side of the running thread, eg. the main thread.

Implements ipfs::http::Transport.

◆ UrlEncode()

void ipfs::http::TransportCurl::UrlEncode ( const std::string &  raw,
std::string *  encoded 
)
overridevirtual

URL encode a string.

URLEcode method is thread-safe.

Parameters
[in]rawInput string to encode.
[out]encodedURL encoded result.

Implements ipfs::http::Transport.


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