2021-09-13 09:37:49 +03:00
|
|
|
/*
|
2022-03-07 11:03:10 +03:00
|
|
|
* Copyright 2022 Haiku Inc. All rights reserved.
|
2021-09-13 09:37:49 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _B_HTTP_SESSION_H_
|
|
|
|
#define _B_HTTP_SESSION_H_
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2022-03-07 11:03:10 +03:00
|
|
|
#include <Messenger.h>
|
|
|
|
|
2021-09-13 09:37:49 +03:00
|
|
|
class BUrl;
|
|
|
|
|
2022-03-07 11:03:10 +03:00
|
|
|
|
2021-09-13 09:37:49 +03:00
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
namespace Network {
|
|
|
|
|
2022-03-07 11:03:10 +03:00
|
|
|
class BHttpRequest;
|
|
|
|
class BHttpResult;
|
|
|
|
|
2021-09-13 09:37:49 +03:00
|
|
|
|
|
|
|
class BHttpSession {
|
|
|
|
public:
|
|
|
|
// Constructors & Destructor
|
|
|
|
BHttpSession();
|
|
|
|
BHttpSession(const BHttpSession&) noexcept;
|
|
|
|
BHttpSession(BHttpSession&&) noexcept = delete;
|
|
|
|
~BHttpSession() noexcept;
|
|
|
|
|
|
|
|
// Assignment operators
|
|
|
|
BHttpSession& operator=(const BHttpSession&) noexcept;
|
|
|
|
BHttpSession& operator=(BHttpSession&&) noexcept = delete;
|
|
|
|
|
2022-03-07 11:03:10 +03:00
|
|
|
// Requests
|
|
|
|
BHttpResult Execute(BHttpRequest&& request,
|
|
|
|
std::unique_ptr<BDataIO> target = nullptr,
|
|
|
|
BMessenger observer = BMessenger());
|
2022-06-03 15:37:26 +03:00
|
|
|
void Cancel(int32 identifier);
|
|
|
|
void Cancel(const BHttpResult& request);
|
2022-03-07 11:03:10 +03:00
|
|
|
|
2022-07-27 11:02:09 +03:00
|
|
|
// Concurrency limits
|
|
|
|
void SetMaxConnectionsPerHost(size_t maxConnections);
|
|
|
|
void SetMaxHosts(size_t maxConnections);
|
|
|
|
|
2021-09-13 09:37:49 +03:00
|
|
|
private:
|
2022-04-23 20:30:38 +03:00
|
|
|
struct Redirect;
|
2021-09-14 10:15:30 +03:00
|
|
|
class Request;
|
|
|
|
class Impl;
|
2021-09-13 09:37:49 +03:00
|
|
|
std::shared_ptr<Impl> fImpl;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-07-24 10:56:02 +03:00
|
|
|
namespace UrlEvent {
|
|
|
|
enum {
|
|
|
|
HttpStatus = '_HST',
|
|
|
|
HttpFields = '_HHF',
|
|
|
|
CertificateError = '_CER',
|
|
|
|
HttpRedirect = '_HRE'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace UrlEventData {
|
|
|
|
extern const char* HttpStatusCode;
|
|
|
|
extern const char* SSLCertificate;
|
|
|
|
extern const char* SSLMessage;
|
|
|
|
extern const char* HttpRedirectUrl;
|
|
|
|
}
|
|
|
|
|
2022-04-03 10:49:05 +03:00
|
|
|
} // namespace Network
|
2021-09-13 09:37:49 +03:00
|
|
|
|
2022-04-03 10:49:05 +03:00
|
|
|
} // namespace BPrivate
|
2021-09-13 09:37:49 +03:00
|
|
|
|
2022-04-03 10:49:05 +03:00
|
|
|
#endif // _B_HTTP_SESSION_H_
|