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_REQUEST_H_
|
|
|
|
#define _B_URL_REQUEST_H_
|
|
|
|
|
|
|
|
|
|
|
|
#include <HttpHeaders.h>
|
|
|
|
#include <Url.h>
|
|
|
|
#include <UrlResult.h>
|
|
|
|
#include <UrlContext.h>
|
|
|
|
#include <UrlProtocol.h>
|
|
|
|
#include <UrlProtocolListener.h>
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
B_NO_HANDLER_FOR_PROTOCOL = B_ERROR
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BUrlRequest {
|
|
|
|
public:
|
|
|
|
BUrlRequest(const BUrl& url,
|
2013-02-11 00:36:34 +04:00
|
|
|
BUrlProtocolListener* listener = NULL,
|
|
|
|
BUrlContext* context = NULL);
|
2010-10-27 18:03:31 +04:00
|
|
|
BUrlRequest(const BUrlRequest& other);
|
2013-02-11 00:36:34 +04:00
|
|
|
virtual ~BUrlRequest();
|
2010-10-27 18:03:31 +04:00
|
|
|
|
|
|
|
// Request parameters modification
|
|
|
|
status_t SetUrl(const BUrl& url);
|
|
|
|
void SetContext(BUrlContext* context);
|
|
|
|
void SetProtocolListener(
|
|
|
|
BUrlProtocolListener* listener);
|
2013-02-11 00:36:34 +04:00
|
|
|
bool SetProtocolOption(int32 option,
|
2010-10-27 18:03:31 +04:00
|
|
|
void* value);
|
|
|
|
// Request parameters access
|
|
|
|
const BUrlProtocol* Protocol();
|
|
|
|
const BUrlResult& Result();
|
|
|
|
const BUrl& Url();
|
2013-02-11 00:36:34 +04:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Request control
|
2013-02-11 00:36:34 +04:00
|
|
|
virtual status_t Start();
|
2010-10-27 18:03:31 +04:00
|
|
|
virtual status_t Pause();
|
|
|
|
virtual status_t Resume();
|
|
|
|
virtual status_t Abort();
|
2013-02-11 00:36:34 +04:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Request informations
|
2013-02-11 00:36:34 +04:00
|
|
|
virtual status_t InitCheck() const;
|
2010-10-27 18:03:31 +04:00
|
|
|
bool IsRunning() const;
|
|
|
|
status_t Status() const;
|
2013-02-11 00:36:34 +04:00
|
|
|
|
2010-10-27 18:03:31 +04:00
|
|
|
// Overloaded members
|
|
|
|
BUrlRequest& operator=(const BUrlRequest& other);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
BUrlProtocolListener* fListener;
|
|
|
|
BUrlProtocol* fUrlProtocol;
|
|
|
|
BUrlResult fResult;
|
|
|
|
BUrlContext* fContext;
|
|
|
|
BUrl fUrl;
|
2013-02-11 00:36:34 +04:00
|
|
|
status_t fInitStatus;
|
|
|
|
|
|
|
|
private:
|
|
|
|
status_t _SetupProtocol();
|
2010-10-27 18:03:31 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _B_URL_REQUEST_H_
|