2010-10-27 18:03:31 +04:00
|
|
|
/*
|
|
|
|
* 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:
|
2013-10-08 13:30:56 +04:00
|
|
|
BUrlSynchronousRequest(BUrlRequest& asynchronousRequest);
|
2010-10-27 18:03:31 +04:00
|
|
|
virtual ~BUrlSynchronousRequest() { };
|
|
|
|
|
|
|
|
// Synchronous wait
|
|
|
|
virtual status_t Perform();
|
|
|
|
virtual status_t WaitUntilCompletion();
|
|
|
|
|
|
|
|
// Protocol hooks
|
2013-10-08 13:30:56 +04:00
|
|
|
virtual void ConnectionOpened(BUrlRequest* caller);
|
|
|
|
virtual void HostnameResolved(BUrlRequest* caller,
|
2010-10-27 18:03:31 +04:00
|
|
|
const char* ip);
|
2013-10-08 13:30:56 +04:00
|
|
|
virtual void ResponseStarted(BUrlRequest* caller);
|
|
|
|
virtual void HeadersReceived(BUrlRequest* caller);
|
|
|
|
virtual void DataReceived(BUrlRequest* caller,
|
2014-04-12 10:48:57 +04:00
|
|
|
const char* data, off_t position,
|
|
|
|
ssize_t size);
|
2013-10-08 13:30:56 +04:00
|
|
|
virtual void DownloadProgress(BUrlRequest* caller,
|
2010-10-27 18:03:31 +04:00
|
|
|
ssize_t bytesReceived, ssize_t bytesTotal);
|
2013-10-08 13:30:56 +04:00
|
|
|
virtual void UploadProgress(BUrlRequest* caller,
|
2010-10-27 18:03:31 +04:00
|
|
|
ssize_t bytesSent, ssize_t bytesTotal);
|
2013-10-08 13:30:56 +04:00
|
|
|
virtual void RequestCompleted(BUrlRequest* caller,
|
2010-10-27 18:03:31 +04:00
|
|
|
bool success);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool fRequestComplete;
|
2013-10-08 13:30:56 +04:00
|
|
|
BUrlRequest& fWrappedRequest;
|
2010-10-27 18:03:31 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _B_URL_SYNCHRONOUS_REQUEST_H_
|