Audacity 3.2.0
Public Types | Public Member Functions | List of all members
audacity::network_manager::IResponse Class Referenceabstract

Interface, that provides access to the data from the HTTP response. More...

#include <IResponse.h>

Inheritance diagram for audacity::network_manager::IResponse:
[legend]
Collaboration diagram for audacity::network_manager::IResponse:
[legend]

Public Types

using RequestCallback = std::function< void(IResponse *)>
 
using ProgressCallback = std::function< void(int64_t current, int64_t expected)>
 

Public Member Functions

virtual ~IResponse ()=default
 
virtual bool isFinished () const noexcept=0
 
virtual unsigned getHTTPCode () const noexcept=0
 
virtual NetworkError getError () const noexcept=0
 
virtual std::string getErrorString () const =0
 
virtual bool headersReceived () const noexcept=0
 
virtual bool hasHeader (const std::string &headerName) const noexcept=0
 
virtual std::string getHeader (const std::string &headerName) const =0
 
virtual const HeadersListgetHeaders () const noexcept=0
 
virtual const CookiesListgetCookies () const noexcept=0
 
virtual const RequestgetRequest () const noexcept=0
 
virtual std::string getURL () const =0
 
virtual void abort () noexcept=0
 
virtual void setOnDataReceivedCallback (RequestCallback callback)=0
 
virtual void setRequestFinishedCallback (RequestCallback callback)=0
 
virtual void setDownloadProgressCallback (ProgressCallback callback)=0
 Set the download progress callback. More...
 
virtual void setUploadProgressCallback (ProgressCallback callback)=0
 Set the upload progress callback. More...
 
virtual uint64_t getBytesAvailable () const noexcept=0
 
virtual uint64_t readData (void *buffer, uint64_t maxBytesCount)=0
 
template<typename RetVal = std::vector<uint8_t>>
RetVal readAll ()
 
void Cancel () override
 
- Public Member Functions inherited from audacity::concurrency::ICancellable
virtual ~ICancellable ()=default
 
virtual void Cancel ()=0
 

Detailed Description

Interface, that provides access to the data from the HTTP response.

Definition at line 112 of file IResponse.h.

Member Typedef Documentation

◆ ProgressCallback

using audacity::network_manager::IResponse::ProgressCallback = std::function<void(int64_t current, int64_t expected)>

Called when download or upload progress changes. Expected can be zero when transfer encoding does not allow to calculate the size

Definition at line 118 of file IResponse.h.

◆ RequestCallback

Definition at line 115 of file IResponse.h.

Constructor & Destructor Documentation

◆ ~IResponse()

virtual audacity::network_manager::IResponse::~IResponse ( )
virtualdefault

Member Function Documentation

◆ abort()

virtual void audacity::network_manager::IResponse::abort ( )
pure virtualnoexcept

◆ Cancel()

void audacity::network_manager::IResponse::Cancel ( )
inlineoverridevirtual

Implements audacity::concurrency::ICancellable.

Definition at line 180 of file IResponse.h.

181 {
182 abort();
183 }
virtual void abort() noexcept=0

◆ getBytesAvailable()

virtual uint64_t audacity::network_manager::IResponse::getBytesAvailable ( ) const
pure virtualnoexcept

Implemented in audacity::network_manager::CurlResponse, and audacity::network_manager::anonymous_namespace{CurlResponseFactory.cpp}::StubResponse.

Referenced by audacity::cloud::audiocom::sync::anonymous_namespace{RemoteProjectSnapshot.cpp}::ReadResponseData().

Here is the caller graph for this function:

◆ getCookies()

virtual const CookiesList & audacity::network_manager::IResponse::getCookies ( ) const
pure virtualnoexcept

◆ getError()

virtual NetworkError audacity::network_manager::IResponse::getError ( ) const
pure virtualnoexcept

Implemented in audacity::network_manager::CurlResponse, and audacity::network_manager::anonymous_namespace{CurlResponseFactory.cpp}::StubResponse.

Referenced by audacity::cloud::audiocom::sync::DeduceUploadError(), and audacity::cloud::audiocom::GetResponseResult().

Here is the caller graph for this function:

◆ getErrorString()

virtual std::string audacity::network_manager::IResponse::getErrorString ( ) const
pure virtual

Implemented in audacity::network_manager::CurlResponse, and audacity::network_manager::anonymous_namespace{CurlResponseFactory.cpp}::StubResponse.

Referenced by audacity::cloud::audiocom::sync::DeduceUploadError(), and audacity::cloud::audiocom::GetResponseResult().

Here is the caller graph for this function:

◆ getHeader()

virtual std::string audacity::network_manager::IResponse::getHeader ( const std::string &  headerName) const
pure virtual

◆ getHeaders()

virtual const HeadersList & audacity::network_manager::IResponse::getHeaders ( ) const
pure virtualnoexcept

◆ getHTTPCode()

virtual unsigned audacity::network_manager::IResponse::getHTTPCode ( ) const
pure virtualnoexcept

Implemented in audacity::network_manager::CurlResponse, and audacity::network_manager::anonymous_namespace{CurlResponseFactory.cpp}::StubResponse.

Referenced by audacity::cloud::audiocom::sync::DeduceUploadError(), and audacity::cloud::audiocom::GetResponseResult().

Here is the caller graph for this function:

◆ getRequest()

virtual const Request & audacity::network_manager::IResponse::getRequest ( ) const
pure virtualnoexcept

◆ getURL()

virtual std::string audacity::network_manager::IResponse::getURL ( ) const
pure virtual

◆ hasHeader()

virtual bool audacity::network_manager::IResponse::hasHeader ( const std::string &  headerName) const
pure virtualnoexcept

◆ headersReceived()

virtual bool audacity::network_manager::IResponse::headersReceived ( ) const
pure virtualnoexcept

◆ isFinished()

virtual bool audacity::network_manager::IResponse::isFinished ( ) const
pure virtualnoexcept

◆ readAll()

template<typename RetVal = std::vector<uint8_t>>
RetVal audacity::network_manager::IResponse::readAll ( )
inline

Definition at line 157 of file IResponse.h.

158 {
159 RetVal result;
160
161 constexpr uint64_t bufferSize = 4 * 1024;
162 uint8_t buffer[bufferSize];
163
164 while (uint64_t bytesRead = readData (buffer, bufferSize))
165 {
166 using PtrType = typename RetVal::pointer;
167
168 PtrType begin = reinterpret_cast<PtrType>(buffer);
169 PtrType end = reinterpret_cast<PtrType>(buffer + bytesRead);
170
171 result.insert (result.end (), begin, end);
172
173 if (bytesRead < bufferSize)
174 break;
175 }
176
177 return result;
178 }
virtual uint64_t readData(void *buffer, uint64_t maxBytesCount)=0
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101

References details::begin(), and details::end().

Referenced by audacity::cloud::audiocom::sync::DeduceUploadError(), audacity::cloud::audiocom::GetResponseResult(), and audacity::cloud::audiocom::sync::anonymous_namespace{RemoteProjectSnapshot.cpp}::ReadResponseData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readData()

virtual uint64_t audacity::network_manager::IResponse::readData ( void *  buffer,
uint64_t  maxBytesCount 
)
pure virtual

Implemented in audacity::network_manager::anonymous_namespace{CurlResponseFactory.cpp}::StubResponse, and audacity::network_manager::CurlResponse.

Referenced by audacity::cloud::audiocom::sync::anonymous_namespace{RemoteProjectSnapshot.cpp}::ReadResponseData().

Here is the caller graph for this function:

◆ setDownloadProgressCallback()

virtual void audacity::network_manager::IResponse::setDownloadProgressCallback ( ProgressCallback  callback)
pure virtual

◆ setOnDataReceivedCallback()

virtual void audacity::network_manager::IResponse::setOnDataReceivedCallback ( RequestCallback  callback)
pure virtual

◆ setRequestFinishedCallback()

virtual void audacity::network_manager::IResponse::setRequestFinishedCallback ( RequestCallback  callback)
pure virtual

◆ setUploadProgressCallback()

virtual void audacity::network_manager::IResponse::setUploadProgressCallback ( ProgressCallback  callback)
pure virtual

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