http: segment resolving & connection from request

set connection id to unsigned int
      use service string instead of int port
      segment connection from request
      save endpoint associated with a conn
      add Connection is_v6 ip method
      propagate resolve errors
This commit is contained in:
Seva committed 2019-07-03 10:30:33 -04:00
1 parent 0e509318bb
commit 93f7251805
5 files changed
+304 -232

No files matched your search

+7 -3
View File
@@ -83,9 +83,8 @@ DhtProxyServer::DhtProxyServer(std::shared_ptr<DhtRunner> dht, in_port_t port,
));
// build http client
auto pushHostPort = splitPort(pushServer_);
uint16_t pushPort = std::atoi(pushHostPort.second.c_str());
httpClient_.reset(new http::Client(httpServer_->io_context(),
pushHostPort.first, pushPort, logger_));
pushHostPort.first, pushHostPort.second, logger_));
// run http server
httpServerThread_ = std::thread([this](){
try {
@@ -663,7 +662,12 @@ DhtProxyServer::sendPushNotification(const std::string& token, Json::Value&& jso
};
auto request = httpClient_->create_request(header, header_fields,
restinio::http_connection_header_t::close, body);
httpClient_->post_request(request, parser, parser_s);
httpClient_->async_connect([this, request, parser, parser_s]
(std::shared_ptr<http::Connection> conn)
{
httpClient_->async_request(conn, request, parser, parser_s);
});
}
#endif //OPENDHT_PUSH_NOTIFICATIONS