-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHttpSession.h
85 lines (65 loc) · 1.84 KB
/
HttpSession.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* Copyright 2021 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _B_HTTP_SESSION_H_
#define _B_HTTP_SESSION_H_
#include <future>
#include <memory>
#include <Messenger.h>
namespace BPrivate {
namespace Network {
class BHttpRequest;
class BHttpResult;
class BHttpSession {
public:
// Constructor & Destructor
BHttpSession();
~BHttpSession() = default;
// Session modifiers
void SetCookieJar() { }
void AddAuthentication() { }
void SetProxy() { }
void AddCertificateException() { }
// Session Accessors
void GetCookieJar() { }
void GetAuthentication() { }
bool UseProxy() { return false; }
void GetProxyHost() { }
void GetProxyPort() { }
bool HasCertificateException() { return false; }
// Requests
BHttpResult AddRequest(BHttpRequest request,
std::unique_ptr<BDataIO> target = nullptr,
BMessenger observer = BMessenger());
void Cancel(int32 identifier);
void Cancel(const BHttpResult& result);
private:
struct Wrapper;
struct Data;
std::shared_ptr<Data> fData;
static status_t ControlThreadFunc(void* arg);
static status_t DataThreadFunc(void* arg);
// Helper Functions
static void _ResolveHostName(Wrapper& request);
static void _OpenConnection(Wrapper& request);
static std::string _CreateRequestHeaders(Wrapper& request);
static bool _RequestRead(Wrapper& request);
static void _ParseStatus(Wrapper& request);
static void _ParseHeaders(Wrapper& request);
};
namespace UrlEvent {
enum {
HttpStatus = '_HST',
HttpHeaders = '_HHD',
CertificateError = '_CER'
};
}
namespace UrlEventData {
extern const char* HttpStatus;
extern const char* SSLCertificate;
extern const char* SSLMessage;
}
} // namespace Network
} // namespace BPrivate
#endif // _B_HTTP_SESSION