1
1
#pragma once
2
2
3
+ #include " address.hpp"
3
4
#include " dns.hpp"
4
5
#include " format.hpp"
5
6
#include " loop.hpp"
6
- #include " session .hpp"
7
+ #include " request .hpp"
7
8
8
9
namespace wshttp
9
10
{
10
11
using namespace wshttp ::literals;
11
12
12
13
struct ssl_creds ;
14
+ class listener ;
13
15
14
16
namespace dns
15
17
{
@@ -71,7 +73,7 @@ namespace wshttp
71
73
std::unordered_map<uint16_t , std::shared_ptr<listener>> _listeners{};
72
74
73
75
// sessions managing outbound https connections
74
- std::unordered_map<domain_host, std::shared_ptr<outbound_node>> _outbounds{};
76
+ // std::unordered_map<domain_host, std::shared_ptr<outbound_node>> _outbounds{};
75
77
76
78
std::atomic<bool > _close_immediately{false };
77
79
@@ -94,35 +96,37 @@ namespace wshttp
94
96
});
95
97
}
96
98
97
- template <typename ... Opt>
98
- bool connect (std::string_view url, Opt&&... opts)
99
- {
100
- return call_get ([&]() {
101
- auto _uri = uri::parse (url);
102
- if (not _uri)
103
- throw std::invalid_argument{" Failed to parse input url: {}" _format (url)};
99
+ // template <typename... Opt>
100
+ // bool connect(std::string_view url, Opt&&... opts)
101
+ // {
102
+ // return call_get([&]() {
103
+ // auto _uri = uri::parse(url);
104
+ // if (not _uri)
105
+ // throw std::invalid_argument{"Failed to parse input url: {}"_format(url)};
104
106
105
- auto [itr, b] = _outbounds.try_emplace (_uri.host_url (), nullptr );
107
+ // auto [itr, b] = _outbounds.try_emplace(_uri.host_url(), nullptr);
106
108
107
- if (not b)
108
- throw std::invalid_argument{
109
- " Cannot create outbound node for input: {} -- node already exists!" _format (url)};
109
+ // if (not b)
110
+ // throw std::invalid_argument{
111
+ // "Cannot create outbound node for input: {} -- node already exists!"_format(url)};
110
112
111
- itr->second = make_shared<outbound_node>(*this , std::move (_uri), std::forward<Opt>(opts)...);
113
+ // itr->second = make_shared<outbound_node>(*this, std::move(_uri), std::forward<Opt>(opts)...);
112
114
113
- if (not itr->second )
114
- throw std::runtime_error{" Node construction is fucked" };
115
+ // if (not itr->second)
116
+ // throw std::runtime_error{"Node construction is fucked"};
115
117
116
- return true ;
117
- });
118
- }
118
+ // return true;
119
+ // });
120
+ // }
119
121
120
122
void test_parse_method (std::string url);
121
123
122
124
const std::shared_ptr<event_loop>& loop () { return _loop; }
123
125
124
126
void set_shutdown_immediate (bool b = true ) { _close_immediately = b; }
125
127
128
+ bool in_event_loop () const { return _loop->in_event_loop (); }
129
+
126
130
protected:
127
131
template <typename T, typename Callable>
128
132
std::shared_ptr<T> shared_ptr (T* obj, Callable&& deleter)
@@ -136,17 +140,18 @@ namespace wshttp
136
140
return _loop->template make_shared <T>(std::forward<Args>(args)...);
137
141
}
138
142
139
- void close_node (domain_host d);
140
143
void close_listener (uint16_t p);
141
144
142
- bool in_event_loop () const { return _loop->in_event_loop (); }
143
-
144
145
void shutdown_endpoint ();
145
146
146
147
SSL_CTX* inbound_ctx ();
147
148
148
149
SSL_CTX* outbound_ctx ();
149
150
151
+ struct event_base * ev_base () { return loop ()->loop ().get (); }
152
+
153
+ struct evhttp * make_evhttp ();
154
+
150
155
private:
151
156
void handle_ep_opt (std::shared_ptr<ssl_creds> c);
152
157
0 commit comments