cfc4b62367
* 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.
46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
/*
|
|
* Copyright 2010 Haiku Inc. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _B_URL_SYNCHRONOUS_REQUEST_H_
|
|
#define _B_URL_SYNCHRONOUS_REQUEST_H_
|
|
|
|
|
|
#include <UrlRequest.h>
|
|
#include <UrlProtocolListener.h>
|
|
|
|
|
|
class BUrlSynchronousRequest : public BUrlRequest, public BUrlProtocolListener {
|
|
public:
|
|
BUrlSynchronousRequest(BUrlRequest& asynchronousRequest);
|
|
virtual ~BUrlSynchronousRequest() { };
|
|
|
|
// Synchronous wait
|
|
virtual status_t Perform();
|
|
virtual status_t WaitUntilCompletion();
|
|
|
|
// Protocol hooks
|
|
virtual void ConnectionOpened(BUrlRequest* caller);
|
|
virtual void HostnameResolved(BUrlRequest* caller,
|
|
const char* ip);
|
|
virtual void ResponseStarted(BUrlRequest* caller);
|
|
virtual void HeadersReceived(BUrlRequest* caller);
|
|
virtual void DataReceived(BUrlRequest* caller,
|
|
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,
|
|
ssize_t bytesSent, ssize_t bytesTotal);
|
|
virtual void RequestCompleted(BUrlRequest* caller,
|
|
bool success);
|
|
|
|
|
|
protected:
|
|
bool fRequestComplete;
|
|
BUrlRequest& fWrappedRequest;
|
|
};
|
|
|
|
|
|
#endif // _B_URL_SYNCHRONOUS_REQUEST_H_
|