libzypp 17.31.23
|
#include </home/abuild/rpmbuild/BUILD/libzypp-17.31.23/zypp-curl/ng/network/request.h>
Classes | |
struct | Range |
struct | Timings |
Public Types | |
enum | State { Pending , Running , Finished , Error } |
enum | Priority { Normal , High , Critical = 100 } |
enum | FileMode { WriteExclusive , WriteShared } |
enum | OptionBits { Default = 0x00 , HeadRequest = 0x01 , ConnectionTest = 0x02 } |
using | Ptr = std::shared_ptr< NetworkRequest > |
using | WeakPtr = std::weak_ptr< NetworkRequest > |
using | DigestPtr = std::shared_ptr< zypp::Digest > |
using | CheckSumBytes = UByteArray |
Public Member Functions | |
ZYPP_DECLARE_FLAGS (Options, OptionBits) | |
NetworkRequest (Url url, zypp::Pathname targetFile, FileMode fMode=WriteExclusive) | |
virtual | ~NetworkRequest () |
void | setExpectedFileSize (zypp::ByteCount expectedFileSize) |
void | setPriority (Priority prio, bool triggerReschedule=true) |
Priority | priority () const |
void | setOptions (Options opt) |
Options | options () const |
void | addRequestRange (size_t start, size_t len=0, DigestPtr digest=nullptr, CheckSumBytes expectedChkSum=CheckSumBytes(), std::any userData=std::any(), std::optional< size_t > digestCompareLen={}, std::optional< size_t > chksumpad={}) |
void | addRequestRange (const Range &range) |
void | resetRequestRanges () |
std::vector< Range > | failedRanges () const |
const std::vector< Range > & | requestedRanges () const |
const std::string & | lastRedirectInfo () const |
void * | nativeHandle () const |
std::optional< Timings > | timings () const |
After the request is finished query the timings that were collected during download. | |
std::vector< char > | peekData (off_t offset, size_t count) const |
Url | url () const |
void | setUrl (const Url &url) |
This will change the URL of the request. | |
const zypp::Pathname & | targetFilePath () const |
Returns the target filename path. | |
void | setTargetFilePath (const zypp::Pathname &path) |
Changes the target file path of the download. | |
FileMode | fileOpenMode () const |
Returns the currently configured file open mode. | |
void | setFileOpenMode (FileMode mode) |
Sets the file open mode to mode. | |
std::string | contentType () const |
Returns the content type as reported from the server. | |
zypp::ByteCount | reportedByteCount () const |
Returns the number of bytes that are reported from the backend as the full download size, those can be 0 even when the download is already running. | |
zypp::ByteCount | downloadedByteCount () const |
Returns the number of already downloaded bytes as reported by the backend. | |
TransferSettings & | transferSettings () |
State | state () const |
Returns the current state the HttpDownloadRequest is in. | |
NetworkRequestError | error () const |
Returns the last set Error. | |
std::string | extendedErrorString () const |
In some cases, curl can provide extended error information collected at runtime. | |
bool | hasError () const |
Checks if there was a error with the request. | |
bool | addRequestHeader (const std::string &header) |
SignalProxy< void(NetworkRequest &req)> | sigStarted () |
Signals that the dispatcher dequeued the request and actually starts downloading data. | |
SignalProxy< void(NetworkRequest &req, zypp::ByteCount count)> | sigBytesDownloaded () |
Signals that new data has been downloaded, this is only the payload and does not include control data bytes. | |
SignalProxy< void(NetworkRequest &req, off_t dltotal, off_t dlnow, off_t ultotal, off_t ulnow)> | sigProgress () |
Signals if there was data read from the download. | |
SignalProxy< void(NetworkRequest &req, const NetworkRequestError &err)> | sigFinished () |
Signals that the download finished. | |
Friends | |
class | NetworkRequestDispatcher |
class | NetworkRequestDispatcherPrivate |
Represents a (http/https/ftp) request. This is the low level API for the
using zyppng::NetworkRequest::Ptr = std::shared_ptr<NetworkRequest> |
using zyppng::NetworkRequest::WeakPtr = std::weak_ptr<NetworkRequest> |
using zyppng::NetworkRequest::DigestPtr = std::shared_ptr<zypp::Digest> |
using zyppng::NetworkRequest::CheckSumBytes = UByteArray |
zyppng::NetworkRequest::NetworkRequest | ( | Url | url, |
zypp::Pathname | targetFile, | ||
FileMode | fMode = WriteExclusive |
||
) |
url | The source URL of the download |
targetFile | The path where the file should be stored |
fMode | The mode in which the file is opened in. |
Definition at line 1109 of file request.cc.
|
virtual |
Definition at line 1114 of file request.cc.
zyppng::NetworkRequest::ZYPP_DECLARE_FLAGS | ( | Options | , |
OptionBits | |||
) |
void zyppng::NetworkRequest::setExpectedFileSize | ( | zypp::ByteCount | expectedFileSize | ) |
Sets the expected file size for the download. In case of a Multi-Range-Download the NetworkRequest will check if the download would write behind the expectedFileSize and fail.
Definition at line 1122 of file request.cc.
void zyppng::NetworkRequest::setPriority | ( | NetworkRequest::Priority | prio, |
bool | triggerReschedule = true |
||
) |
Sets the priority of the NetworkRequest, this will affect where the
Definition at line 1127 of file request.cc.
NetworkRequest::Priority zyppng::NetworkRequest::priority | ( | ) | const |
Returns the requested priority of the NetworkRequest
Definition at line 1135 of file request.cc.
void zyppng::NetworkRequest::setOptions | ( | Options | opt | ) |
Change request options.
Definition at line 1140 of file request.cc.
NetworkRequest::Options zyppng::NetworkRequest::options | ( | ) | const |
Returns the currently set options
Definition at line 1145 of file request.cc.
void zyppng::NetworkRequest::addRequestRange | ( | size_t | start, |
size_t | len = 0 , |
||
DigestPtr | digest = nullptr , |
||
CheckSumBytes | expectedChkSum = CheckSumBytes() , |
||
std::any | userData = std::any() , |
||
std::optional< size_t > | digestCompareLen = {} , |
||
std::optional< size_t > | chksumpad = {} |
||
) |
Adds a new range to the requested range list, the ranges can not overlap
Definition at line 1150 of file request.cc.
void zyppng::NetworkRequest::addRequestRange | ( | const Range & | range | ) |
Definition at line 1159 of file request.cc.
void zyppng::NetworkRequest::resetRequestRanges | ( | ) |
Clears all requested ranges, the next download will get the complete file
Definition at line 1173 of file request.cc.
std::vector< NetworkRequest::Range > zyppng::NetworkRequest::failedRanges | ( | ) | const |
Definition at line 1181 of file request.cc.
const std::vector< NetworkRequest::Range > & zyppng::NetworkRequest::requestedRanges | ( | ) | const |
Definition at line 1197 of file request.cc.
const std::string & zyppng::NetworkRequest::lastRedirectInfo | ( | ) | const |
Returns the last redirect information from the headers.
Definition at line 1202 of file request.cc.
void * zyppng::NetworkRequest::nativeHandle | ( | ) | const |
Returns a pointer to the native CURL easy handle
Definition at line 1207 of file request.cc.
std::optional< zyppng::NetworkRequest::Timings > zyppng::NetworkRequest::timings | ( | ) | const |
After the request is finished query the timings that were collected during download.
Definition at line 1212 of file request.cc.
std::vector< char > zyppng::NetworkRequest::peekData | ( | off_t | offset, |
size_t | count | ||
) | const |
Will return the data at offset with length count. If there is not yet enough data a empty vector will be returned
Definition at line 1240 of file request.cc.
Url zyppng::NetworkRequest::url | ( | ) | const |
Returns the request URL
Definition at line 1251 of file request.cc.
void zyppng::NetworkRequest::setUrl | ( | const Url & | url | ) |
This will change the URL of the request.
Definition at line 1256 of file request.cc.
const zypp::filesystem::Pathname & zyppng::NetworkRequest::targetFilePath | ( | ) | const |
Returns the target filename path.
Definition at line 1265 of file request.cc.
void zyppng::NetworkRequest::setTargetFilePath | ( | const zypp::Pathname & | path | ) |
Changes the target file path of the download.
Definition at line 1270 of file request.cc.
NetworkRequest::FileMode zyppng::NetworkRequest::fileOpenMode | ( | ) | const |
Returns the currently configured file open mode.
Definition at line 1278 of file request.cc.
void zyppng::NetworkRequest::setFileOpenMode | ( | FileMode | mode | ) |
Sets the file open mode to mode.
Definition at line 1283 of file request.cc.
std::string zyppng::NetworkRequest::contentType | ( | ) | const |
Returns the content type as reported from the server.
Definition at line 1291 of file request.cc.
zypp::ByteCount zyppng::NetworkRequest::reportedByteCount | ( | ) | const |
Returns the number of bytes that are reported from the backend as the full download size, those can be 0 even when the download is already running.
Definition at line 1299 of file request.cc.
zypp::ByteCount zyppng::NetworkRequest::downloadedByteCount | ( | ) | const |
Returns the number of already downloaded bytes as reported by the backend.
Definition at line 1313 of file request.cc.
TransferSettings & zyppng::NetworkRequest::transferSettings | ( | ) |
Returns a writeable reference to the internal
Definition at line 1328 of file request.cc.
NetworkRequest::State zyppng::NetworkRequest::state | ( | ) | const |
Returns the current state the HttpDownloadRequest is in.
Definition at line 1333 of file request.cc.
NetworkRequestError zyppng::NetworkRequest::error | ( | ) | const |
Returns the last set Error.
Definition at line 1352 of file request.cc.
std::string zyppng::NetworkRequest::extendedErrorString | ( | ) | const |
In some cases, curl can provide extended error information collected at runtime.
In those cases, it is possible to query that information.
Definition at line 1360 of file request.cc.
bool zyppng::NetworkRequest::hasError | ( | ) | const |
Checks if there was a error with the request.
Definition at line 1368 of file request.cc.
bool zyppng::NetworkRequest::addRequestHeader | ( | const std::string & | header | ) |
Adds a raw header to the request data. Use this to send custom headers to the server.
Definition at line 1373 of file request.cc.
SignalProxy< void(NetworkRequest &req)> zyppng::NetworkRequest::sigStarted | ( | ) |
Signals that the dispatcher dequeued the request and actually starts downloading data.
Definition at line 1387 of file request.cc.
SignalProxy< void(NetworkRequest &req, zypp::ByteCount count)> zyppng::NetworkRequest::sigBytesDownloaded | ( | ) |
Signals that new data has been downloaded, this is only the payload and does not include control data bytes.
Definition at line 1392 of file request.cc.
SignalProxy< void(NetworkRequest &req, off_t dltotal, off_t dlnow, off_t ultotal, off_t ulnow)> zyppng::NetworkRequest::sigProgress | ( | ) |
Signals if there was data read from the download.
Definition at line 1397 of file request.cc.
SignalProxy< void(zyppng::NetworkRequest &req, const zyppng::NetworkRequestError &err)> zyppng::NetworkRequest::sigFinished | ( | ) |
Signals that the download finished.
Definition at line 1402 of file request.cc.
|
friend |