Made Client::create_request_header const, and cleanup of indentations in Client

This commit is contained in:
eidheim 2017-06-12 08:22:40 +02:00
commit a0cd7520ba
2 changed files with 15 additions and 26 deletions

View file

@ -50,8 +50,7 @@ namespace SimpleWeb {
auto proxy_host_port=parse_host_port(config.proxy_server, 8080);
query=std::unique_ptr<asio::ip::tcp::resolver::query>(new asio::ip::tcp::resolver::query(proxy_host_port.first, std::to_string(proxy_host_port.second)));
}
resolver.async_resolve(*query, [this]
(const error_code &ec, asio::ip::tcp::resolver::iterator it){
resolver.async_resolve(*query, [this] (const error_code &ec, asio::ip::tcp::resolver::iterator it){
if(!ec) {
{
std::lock_guard<std::mutex> lock(socket_mutex);
@ -59,8 +58,7 @@ namespace SimpleWeb {
}
auto timer=get_timeout_timer(config.timeout_connect);
asio::async_connect(socket->lowest_layer(), it, [this, timer]
(const error_code &ec, asio::ip::tcp::resolver::iterator /*it*/){
asio::async_connect(socket->lowest_layer(), it, [this, timer] (const error_code &ec, asio::ip::tcp::resolver::iterator /*it*/){
if(timer)
timer->cancel();
if(!ec) {
@ -89,8 +87,7 @@ namespace SimpleWeb {
auto host_port=host+':'+std::to_string(port);
write_stream << "CONNECT "+host_port+" HTTP/1.1\r\n" << "Host: " << host_port << "\r\n\r\n";
auto timer=get_timeout_timer();
asio::async_write(socket->next_layer(), write_buffer,
[this, timer](const error_code &ec, size_t /*bytes_transferred*/) {
asio::async_write(socket->next_layer(), write_buffer, [this, timer](const error_code &ec, size_t /*bytes_transferred*/) {
if(timer)
timer->cancel();
if(ec) {
@ -104,8 +101,7 @@ namespace SimpleWeb {
std::shared_ptr<Response> response(new Response());
timer=get_timeout_timer();
asio::async_read_until(socket->next_layer(), response->content_buffer, "\r\n\r\n",
[this, timer](const error_code& ec, size_t /*bytes_transferred*/) {
asio::async_read_until(socket->next_layer(), response->content_buffer, "\r\n\r\n", [this, timer](const error_code& ec, size_t /*bytes_transferred*/) {
if(timer)
timer->cancel();
if(ec) {
@ -125,8 +121,7 @@ namespace SimpleWeb {
}
auto timer=get_timeout_timer();
this->socket->async_handshake(asio::ssl::stream_base::client,
[this, timer](const error_code& ec) {
this->socket->async_handshake(asio::ssl::stream_base::client, [this, timer](const error_code& ec) {
if(timer)
timer->cancel();
if(ec) {