Network Kit: Prepare for HTTP range requests
* The DataReceived hook gets a position argument, making it possible for listeners to handle out-of-order data (from two range requests at different positions, for example) * Adjust HaikuDepot (only user of the API in our sources) * Add a copy constructor to HTTPRequest that copies the relevant parameters from an existing request. Makes it easy to repeat a request with a different range. Could be useful for restarting downloads, or paralellizing them. * Add SetRangeStart, SetRangeEnd calls to HTTPRequest, no implementation yet. I'm putting all the API changes in this commit as it needs to be synced with a matching haikuwebkit release. * All archs must update to HaikuWebkit 1.3.0. Previous versions are broken by this.
This commit is contained in:
@@ -26,6 +26,7 @@ public:
|
||||
const char *protocolName = "HTTP",
|
||||
BUrlProtocolListener* listener = NULL,
|
||||
BUrlContext* context = NULL);
|
||||
BHttpRequest(const BHttpRequest& other);
|
||||
virtual ~BHttpRequest();
|
||||
|
||||
void SetMethod(const char* const method);
|
||||
@@ -38,6 +39,8 @@ public:
|
||||
void SetAutoReferrer(bool enable);
|
||||
void SetUserName(const BString& name);
|
||||
void SetPassword(const BString& password);
|
||||
void SetRangeStart(off_t position);
|
||||
void SetRangeEnd(off_t position);
|
||||
|
||||
void SetPostFields(const BHttpForm& fields);
|
||||
void SetHeaders(const BHttpHeaders& headers);
|
||||
@@ -115,6 +118,8 @@ private:
|
||||
BHttpForm* fOptPostFields;
|
||||
BDataIO* fOptInputData;
|
||||
ssize_t fOptInputDataSize;
|
||||
off_t fOptRangeStart;
|
||||
off_t fOptRangeEnd;
|
||||
bool fOptSetCookies : 1;
|
||||
bool fOptFollowLocation : 1;
|
||||
bool fOptDiscardData : 1;
|
||||
|
||||
@@ -44,7 +44,8 @@ public:
|
||||
virtual void ResponseStarted(BUrlRequest* caller);
|
||||
virtual void HeadersReceived(BUrlRequest* caller);
|
||||
virtual void DataReceived(BUrlRequest* caller,
|
||||
const char* data, ssize_t size);
|
||||
const char* data, off_t position,
|
||||
ssize_t size);
|
||||
virtual void DownloadProgress(BUrlRequest* caller,
|
||||
ssize_t bytesReceived, ssize_t bytesTotal);
|
||||
virtual void UploadProgress(BUrlRequest* caller,
|
||||
|
||||
@@ -62,15 +62,17 @@ public:
|
||||
virtual void HeadersReceived(BUrlRequest* caller);
|
||||
|
||||
/**
|
||||
DataReceived(data, size)
|
||||
DataReceived(data, position, size)
|
||||
Frequency: Zero or more
|
||||
Parameters: data Pointer to the data block in memory
|
||||
position Offset of the data in the stream
|
||||
size Size of the data block
|
||||
|
||||
Called each time a full block of data is received.
|
||||
*/
|
||||
virtual void DataReceived(BUrlRequest* caller,
|
||||
const char* data, ssize_t size);
|
||||
const char* data, off_t position,
|
||||
ssize_t size);
|
||||
|
||||
/**
|
||||
DownloadProgress(bytesReceived, bytesTotal)
|
||||
|
||||
@@ -26,7 +26,8 @@ public:
|
||||
virtual void ResponseStarted(BUrlRequest* caller);
|
||||
virtual void HeadersReceived(BUrlRequest* caller);
|
||||
virtual void DataReceived(BUrlRequest* caller,
|
||||
const char* data, ssize_t size);
|
||||
const char* data, off_t position,
|
||||
ssize_t size);
|
||||
virtual void DownloadProgress(BUrlRequest* caller,
|
||||
ssize_t bytesReceived, ssize_t bytesTotal);
|
||||
virtual void UploadProgress(BUrlRequest* caller,
|
||||
|
||||
Reference in New Issue
Block a user