1 #ifndef ZYPPNG_CURLMULTIPARTHANDLER_H 2 #define ZYPPNG_CURLMULTIPARTHANDLER_H 4 #include <zypp-core/zyppng/base/Base> 5 #include <zypp-core/zyppng/core/ByteArray> 6 #include <zypp-core/Digest.h> 7 #include <zypp-core/zyppng/pipelines/Expected> 8 #include <zypp-curl/ng/network/NetworkRequestError> 32 virtual size_t writefunction (
char *ptr, std::optional<off_t> offset,
size_t bytes ) = 0;
41 virtual bool beginRange ( off_t range, std::string &cancelReason ) {
return true; };
53 virtual bool finishedRange ( off_t range,
bool validated, std::string &cancelReason ) {
return true; };
120 static Range make (
size_t start,
size_t len = 0, std::optional<zypp::Digest> &&digest = {},
CheckSumBytes &&expectedChkSum =
CheckSumBytes(), std::any &&
userData = std::any(), std::optional<size_t> digestCompareLen = {}, std::optional<size_t> _dataBlockPadding = {} );
148 void setCode (
Code c, std::string msg,
bool force =
false );
150 static size_t curl_hdrcallback (
char *ptr,
size_t size,
size_t nmemb,
void *userdata );
151 static size_t curl_wrtcallback (
char *ptr,
size_t size,
size_t nmemb,
void *userdata );
153 size_t hdrcallback (
char *ptr,
size_t size,
size_t nmemb );
154 size_t wrtcallback (
char *ptr,
size_t size,
size_t nmemb );
184 #endif // ZYPPNG_CURLMULTIPARTHANDLER_H std::optional< size_t > reportedFileSize() const
CurlMultiPartDataReceiver & _receiver
std::optional< size_t > _chksumPad
std::string _seperatorString
The seperator string for multipart responses as defined in RFC 7233 Section 4.1.
The CurlMultiPartHandler class.
virtual ~CurlMultiPartDataReceiver()=default
static Range make(size_t start, size_t len=0, std::optional< zypp::Digest > &&digest={}, CheckSumBytes &&expectedChkSum=CheckSumBytes(), std::any &&userData=std::any(), std::optional< size_t > digestCompareLen={}, std::optional< size_t > _dataBlockPadding={})
size_t hdrcallback(char *ptr, size_t size, size_t nmemb)
NetworkRequestError::Type Code
void setRangeState(Range &rng, State state)
const std::string & lastErrorMessage() const
std::optional< Range > _currentSrvRange
void setCode(Code c, std::string msg, bool force=false)
virtual size_t headerfunction(char *ptr, size_t bytes)=0
CheckSumBytes _checksum
Enables automated checking of downloaded contents against a checksum.
virtual size_t writefunction(char *ptr, std::optional< off_t > offset, size_t bytes)=0
std::vector< Range > & _requestedRanges
the requested ranges that need to be downloaded
std::string _lastErrorMsg
static constexpr unsigned _rangeAttemptSize
CurlMultiPartHandler(ProtocolMode mode, void *easyHandle, std::vector< Range > &ranges, CurlMultiPartDataReceiver &receiver)
virtual bool finishedRange(off_t range, bool validated, std::string &cancelReason)
static size_t curl_wrtcallback(char *ptr, size_t size, size_t nmemb, void *userdata)
std::optional< off_t > currentRange() const
bool checkIfRangeChkSumIsValid(Range &rng)
std::optional< size_t > _relevantDigestLen
virtual bool beginRange(off_t range, std::string &cancelReason)
bool _gotContentRangeInfo
bool validateRange(Range &rng)
unsigned _rangeAttemptIdx
std::vector< char > _rangePrefaceBuffer
Here we buffer.
std::optional< zypp::Digest > _digest
ProtocolMode _protocolMode
std::optional< off_t > _currentRange
std::optional< size_t > _reportedFileSize
Filesize as reported by the content range or byte range headers.
bool parseContentRangeHeader(const std::string_view &line, size_t &start, size_t &len, size_t &fileLen)
static constexpr unsigned _rangeAttempt[]
static size_t curl_hdrcallback(char *ptr, size_t size, size_t nmemb, void *userdata)
bool parseContentTypeMultiRangeHeader(const std::string_view &line, std::string &boundary)
void * easyHandle() const
size_t wrtcallback(char *ptr, size_t size, size_t nmemb)