1/* 2 * Copyright 2022 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6#ifndef _B_HTTP_SESSION_H_ 7#define _B_HTTP_SESSION_H_ 8 9#include <memory> 10 11#include <ExclusiveBorrow.h> 12#include <Messenger.h> 13 14class BUrl; 15 16 17namespace BPrivate { 18 19namespace Network { 20 21class BHttpRequest; 22class BHttpResult; 23 24 25class BHttpSession 26{ 27public: 28 // Constructors & Destructor 29 BHttpSession(); 30 BHttpSession(const BHttpSession&) noexcept; 31 BHttpSession(BHttpSession&&) noexcept = delete; 32 ~BHttpSession() noexcept; 33 34 // Assignment operators 35 BHttpSession& operator=(const BHttpSession&) noexcept; 36 BHttpSession& operator=(BHttpSession&&) noexcept = delete; 37 38 // Requests 39 BHttpResult Execute(BHttpRequest&& request, BBorrow<BDataIO> target = nullptr, 40 BMessenger observer = BMessenger()); 41 void Cancel(int32 identifier); 42 void Cancel(const BHttpResult& request); 43 44 // Concurrency limits 45 void SetMaxConnectionsPerHost(size_t maxConnections); 46 void SetMaxHosts(size_t maxConnections); 47 48private: 49 struct Redirect; 50 class Request; 51 class Impl; 52 std::shared_ptr<Impl> fImpl; 53}; 54 55 56namespace UrlEvent { 57enum { HttpStatus = '_HST', HttpFields = '_HHF', CertificateError = '_CER', HttpRedirect = '_HRE' }; 58} 59 60 61namespace UrlEventData { 62extern const char* HttpStatusCode; 63extern const char* SSLCertificate; 64extern const char* SSLMessage; 65extern const char* HttpRedirectUrl; 66} // namespace UrlEventData 67 68} // namespace Network 69 70} // namespace BPrivate 71 72#endif // _B_HTTP_SESSION_H_ 73