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>
|
|
|
|
|
|
|
|
|
2021-01-22 17:20:19 +03:00
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
namespace Network {
|
2021-09-11 10:09:44 +03:00
|
|
|
|
2021-01-22 17:20:19 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
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() { };
|
2020-07-25 07:45:42 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// 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);
|
2020-07-25 07:45:42 +03:00
|
|
|
virtual void HostnameResolved(BUrlRequest* caller,
|
2010-10-27 18:03:31 +04:00
|
|
|
const char* ip);
|
2020-07-25 07:45:42 +03:00
|
|
|
virtual void ResponseStarted(BUrlRequest* caller);
|
|
|
|
virtual void HeadersReceived(BUrlRequest* caller);
|
|
|
|
virtual void BytesWritten(BUrlRequest* caller,
|
|
|
|
size_t bytesWritten);
|
2021-01-28 14:08:10 +03:00
|
|
|
virtual void DownloadProgress(BUrlRequest* caller,
|
|
|
|
off_t bytesReceived, off_t bytesTotal);
|
|
|
|
virtual void UploadProgress(BUrlRequest* caller,
|
|
|
|
off_t bytesSent, off_t bytesTotal);
|
|
|
|
|
2020-07-25 07:45:42 +03:00
|
|
|
virtual void RequestCompleted(BUrlRequest* caller,
|
2010-10-27 18:03:31 +04:00
|
|
|
bool success);
|
2020-07-25 07:45:42 +03:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
protected:
|
|
|
|
bool fRequestComplete;
|
2013-10-08 13:30:56 +04:00
|
|
|
BUrlRequest& fWrappedRequest;
|
2010-10-27 18:03:31 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-01-22 17:20:19 +03:00
|
|
|
} // namespace Network
|
|
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
#endif // _B_URL_SYNCHRONOUS_REQUEST_H_
|