libzypp 17.35.1
zyppng::CurlMultiPartHandler Class Reference

The CurlMultiPartHandler class. More...

#include <zypp-curl/ng/network/curlmultiparthandler.h>

Inheritance diagram for zyppng::CurlMultiPartHandler:

Classes

struct  Range
 

Public Types

enum class  ProtocolMode { Basic , HTTP }
 
enum  State { Pending , Running , Finished , Error }
 
using CheckSumBytes = UByteArray
 
using Code = NetworkRequestError::Type
 
- Public Types inherited from zyppng::Base
using Ptr = std::shared_ptr<Base>
 
using WeakPtr = std::weak_ptr<Base>
 

Public Member Functions

 CurlMultiPartHandler (ProtocolMode mode, void *easyHandle, std::vector< Range > &ranges, CurlMultiPartDataReceiver &receiver)
 
 ~CurlMultiPartHandler () override
 
voideasyHandle () const
 
bool canRecover () const
 
bool hasMoreWork () const
 
bool hasError () const
 
Code lastError () const
 
const std::string & lastErrorMessage () const
 
bool validateRange (Range &rng)
 
bool prepare ()
 
bool prepareToContinue ()
 
void finalize ()
 
bool verifyData ()
 
std::optional< size_t > reportedFileSize () const
 
std::optional< off_t > currentRange () const
 
- Public Member Functions inherited from zyppng::Base
 Base ()
 
virtual ~Base ()
 
WeakPtr parent () const
 
void addChild (const Base::Ptr &child)
 
void removeChild (const Ptr &child)
 
const std::unordered_set< Ptr > & children () const
 
std::thread::id threadId () const
 
template<typename T >
std::vector< std::weak_ptr< T > > findChildren () const
 
template<typename T >
std::shared_ptr< T > shared_this () const
 
template<typename T >
std::shared_ptr< T > shared_this ()
 
template<typename T >
std::weak_ptr< T > weak_this () const
 
template<typename T >
std::weak_ptr< T > weak_this ()
 
template<typename SenderFunc , typename ReceiverFunc >
auto connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
 
template<typename SenderFunc , typename ReceiverFunc , typename ... Tracker>
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connectionconnectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)
 

Static Public Attributes

static constexpr unsigned _rangeAttempt []
 
static constexpr unsigned _rangeAttemptSize = ( sizeof( _rangeAttempt ) / sizeof(unsigned) )
 

Private Member Functions

void setCode (Code c, std::string msg, bool force=false)
 
size_t hdrcallback (char *ptr, size_t size, size_t nmemb)
 
size_t wrtcallback (char *ptr, size_t size, size_t nmemb)
 
bool parseContentRangeHeader (const std::string_view &line, size_t &start, size_t &len, size_t &fileLen)
 
bool parseContentTypeMultiRangeHeader (const std::string_view &line, std::string &boundary)
 
bool checkIfRangeChkSumIsValid (Range &rng)
 
void setRangeState (Range &rng, State state)
 

Static Private Member Functions

static size_t curl_hdrcallback (char *ptr, size_t size, size_t nmemb, void *userdata)
 
static size_t curl_wrtcallback (char *ptr, size_t size, size_t nmemb, void *userdata)
 

Private Attributes

ProtocolMode _protocolMode = ProtocolMode::HTTP
 
void_easyHandle = nullptr
 
CurlMultiPartDataReceiver_receiver
 
Code _lastCode = Code::NoError
 
std::string _lastErrorMsg
 
bool _allHeadersReceived = false
 
bool _gotContentRangeInfo = false
 
bool _isMuliPartResponse = false
 
std::string _seperatorString
 The seperator string for multipart responses as defined in RFC 7233 Section 4.1.
 
std::vector< char > _rangePrefaceBuffer
 Here we buffer.
 
std::optional< off_t > _currentRange
 
std::optional< Range_currentSrvRange
 
std::optional< size_t > _reportedFileSize
 Filesize as reported by the content range or byte range headers.
 
unsigned _rangeAttemptIdx = 0
 
std::vector< Range > & _requestedRanges
 the requested ranges that need to be downloaded
 

Additional Inherited Members

- Static Public Member Functions inherited from zyppng::Base
template<typename Obj , typename Functor >
static decltype(automake_base_slot (Obj *o, Functor &&f)
 
template<typename SenderFunc , typename ReceiverFunc >
static auto connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc)
 
template<typename SenderFunc , typename ReceiverFunc , typename ... Tracker>
static auto connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers)
 
- Protected Member Functions inherited from zyppng::Base
 Base (BasePrivate &dd)
 
- Protected Attributes inherited from zyppng::Base
std::unique_ptr< BasePrivated_ptr
 

Detailed Description

The CurlMultiPartHandler class.

multirange support for HTTP requests (https://tools.ietf.org/html/rfc7233), if not operating on a HTTP/HTTPS URL this will batch multirange requests one by one, so maybe don't use it there

Definition at line 68 of file curlmultiparthandler.h.

Member Typedef Documentation

◆ CheckSumBytes

◆ Code

Member Enumeration Documentation

◆ ProtocolMode

Enumerator
Basic 
HTTP 

Definition at line 72 of file curlmultiparthandler.h.

◆ State

Enumerator
Pending 
Running 
Finished 
Error 

Definition at line 93 of file curlmultiparthandler.h.

Constructor & Destructor Documentation

◆ CurlMultiPartHandler()

zyppng::CurlMultiPartHandler::CurlMultiPartHandler ( ProtocolMode mode,
void * easyHandle,
std::vector< Range > & ranges,
CurlMultiPartDataReceiver & receiver )

Definition at line 90 of file curlmultiparthandler.cc.

◆ ~CurlMultiPartHandler()

zyppng::CurlMultiPartHandler::~CurlMultiPartHandler ( )
override

Definition at line 103 of file curlmultiparthandler.cc.

Member Function Documentation

◆ easyHandle()

void * zyppng::CurlMultiPartHandler::easyHandle ( ) const

Definition at line 423 of file curlmultiparthandler.cc.

◆ canRecover()

bool zyppng::CurlMultiPartHandler::canRecover ( ) const

Definition at line 428 of file curlmultiparthandler.cc.

◆ hasMoreWork()

bool zyppng::CurlMultiPartHandler::hasMoreWork ( ) const

Definition at line 438 of file curlmultiparthandler.cc.

◆ hasError()

bool zyppng::CurlMultiPartHandler::hasError ( ) const

Definition at line 444 of file curlmultiparthandler.cc.

◆ lastError()

CurlMultiPartHandler::Code zyppng::CurlMultiPartHandler::lastError ( ) const

Definition at line 449 of file curlmultiparthandler.cc.

◆ lastErrorMessage()

const std::string & zyppng::CurlMultiPartHandler::lastErrorMessage ( ) const

Definition at line 454 of file curlmultiparthandler.cc.

◆ validateRange()

bool zyppng::CurlMultiPartHandler::validateRange ( Range & rng)

Definition at line 675 of file curlmultiparthandler.cc.

◆ prepare()

bool zyppng::CurlMultiPartHandler::prepare ( )

Definition at line 510 of file curlmultiparthandler.cc.

◆ prepareToContinue()

bool zyppng::CurlMultiPartHandler::prepareToContinue ( )

Definition at line 459 of file curlmultiparthandler.cc.

◆ finalize()

void zyppng::CurlMultiPartHandler::finalize ( )

Definition at line 478 of file curlmultiparthandler.cc.

◆ verifyData()

bool zyppng::CurlMultiPartHandler::verifyData ( )

Definition at line 490 of file curlmultiparthandler.cc.

◆ reportedFileSize()

std::optional< size_t > zyppng::CurlMultiPartHandler::reportedFileSize ( ) const

Definition at line 723 of file curlmultiparthandler.cc.

◆ currentRange()

std::optional< off_t > zyppng::CurlMultiPartHandler::currentRange ( ) const

Definition at line 718 of file curlmultiparthandler.cc.

◆ setCode()

void zyppng::CurlMultiPartHandler::setCode ( Code c,
std::string msg,
bool force = false )
private

Definition at line 631 of file curlmultiparthandler.cc.

◆ curl_hdrcallback()

size_t zyppng::CurlMultiPartHandler::curl_hdrcallback ( char * ptr,
size_t size,
size_t nmemb,
void * userdata )
staticprivate

Definition at line 35 of file curlmultiparthandler.cc.

◆ curl_wrtcallback()

size_t zyppng::CurlMultiPartHandler::curl_wrtcallback ( char * ptr,
size_t size,
size_t nmemb,
void * userdata )
staticprivate

Definition at line 44 of file curlmultiparthandler.cc.

◆ hdrcallback()

size_t zyppng::CurlMultiPartHandler::hdrcallback ( char * ptr,
size_t size,
size_t nmemb )
private

Definition at line 113 of file curlmultiparthandler.cc.

◆ wrtcallback()

size_t zyppng::CurlMultiPartHandler::wrtcallback ( char * ptr,
size_t size,
size_t nmemb )
private

Definition at line 192 of file curlmultiparthandler.cc.

◆ parseContentRangeHeader()

bool zyppng::CurlMultiPartHandler::parseContentRangeHeader ( const std::string_view & line,
size_t & start,
size_t & len,
size_t & fileLen )
private

Definition at line 642 of file curlmultiparthandler.cc.

◆ parseContentTypeMultiRangeHeader()

bool zyppng::CurlMultiPartHandler::parseContentTypeMultiRangeHeader ( const std::string_view & line,
std::string & boundary )
private

Definition at line 661 of file curlmultiparthandler.cc.

◆ checkIfRangeChkSumIsValid()

bool zyppng::CurlMultiPartHandler::checkIfRangeChkSumIsValid ( Range & rng)
private

Definition at line 691 of file curlmultiparthandler.cc.

◆ setRangeState()

void zyppng::CurlMultiPartHandler::setRangeState ( Range & rng,
State state )
private

Definition at line 711 of file curlmultiparthandler.cc.

Member Data Documentation

◆ _rangeAttempt

constexpr unsigned zyppng::CurlMultiPartHandler::_rangeAttempt[]
staticconstexpr
Initial value:
= {
255,
127,
63,
15,
5,
1
}

Definition at line 82 of file curlmultiparthandler.h.

◆ _rangeAttemptSize

constexpr unsigned zyppng::CurlMultiPartHandler::_rangeAttemptSize = ( sizeof( _rangeAttempt ) / sizeof(unsigned) )
staticconstexpr

Definition at line 91 of file curlmultiparthandler.h.

◆ _protocolMode

ProtocolMode zyppng::CurlMultiPartHandler::_protocolMode = ProtocolMode::HTTP
private

Definition at line 165 of file curlmultiparthandler.h.

◆ _easyHandle

void* zyppng::CurlMultiPartHandler::_easyHandle = nullptr
private

Definition at line 166 of file curlmultiparthandler.h.

◆ _receiver

CurlMultiPartDataReceiver& zyppng::CurlMultiPartHandler::_receiver
private

Definition at line 167 of file curlmultiparthandler.h.

◆ _lastCode

Code zyppng::CurlMultiPartHandler::_lastCode = Code::NoError
private

Definition at line 169 of file curlmultiparthandler.h.

◆ _lastErrorMsg

std::string zyppng::CurlMultiPartHandler::_lastErrorMsg
private

Definition at line 170 of file curlmultiparthandler.h.

◆ _allHeadersReceived

bool zyppng::CurlMultiPartHandler::_allHeadersReceived = false
private

Definition at line 172 of file curlmultiparthandler.h.

◆ _gotContentRangeInfo

bool zyppng::CurlMultiPartHandler::_gotContentRangeInfo = false
private

Definition at line 173 of file curlmultiparthandler.h.

◆ _isMuliPartResponse

bool zyppng::CurlMultiPartHandler::_isMuliPartResponse = false
private

Definition at line 174 of file curlmultiparthandler.h.

◆ _seperatorString

std::string zyppng::CurlMultiPartHandler::_seperatorString
private

The seperator string for multipart responses as defined in RFC 7233 Section 4.1.

Definition at line 176 of file curlmultiparthandler.h.

◆ _rangePrefaceBuffer

std::vector<char> zyppng::CurlMultiPartHandler::_rangePrefaceBuffer
private

Here we buffer.

Definition at line 177 of file curlmultiparthandler.h.

◆ _currentRange

std::optional<off_t> zyppng::CurlMultiPartHandler::_currentRange
private

Definition at line 179 of file curlmultiparthandler.h.

◆ _currentSrvRange

std::optional<Range> zyppng::CurlMultiPartHandler::_currentSrvRange
private

Definition at line 180 of file curlmultiparthandler.h.

◆ _reportedFileSize

std::optional<size_t> zyppng::CurlMultiPartHandler::_reportedFileSize
private

Filesize as reported by the content range or byte range headers.

Definition at line 181 of file curlmultiparthandler.h.

◆ _rangeAttemptIdx

unsigned zyppng::CurlMultiPartHandler::_rangeAttemptIdx = 0
private

Definition at line 183 of file curlmultiparthandler.h.

◆ _requestedRanges

std::vector<Range>& zyppng::CurlMultiPartHandler::_requestedRanges
private

the requested ranges that need to be downloaded

Definition at line 184 of file curlmultiparthandler.h.


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