Last active
December 10, 2015 20:58
-
-
Save alibitek/4491787 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void http_session::handle_write(const error_code& ec,std::size_t sz) | |
{ | |
if(!ec) | |
{ | |
if(keep_alive_) | |
{ | |
handle_handshake(error_code()); | |
} | |
else | |
{ | |
this->end(c_handler_); | |
return; | |
} | |
} | |
} | |
void http_session::handle_handshake(const error_code& ec) | |
{ | |
if(!ec) | |
{ | |
read_buf_.reset(new boost::asio::streambuf()); | |
boost::asio::async_read_until(*socket_,*read_buf_.get(), | |
"\r\n\r\n", | |
boost::bind(&http_session::handle_header_read,shared_from_this(), | |
boost::asio::placeholders::error, | |
boost::asio::placeholders::bytes_transferred)); | |
read_timer_.expires_from_now(boost::posix_time::seconds(5)); | |
read_timer_.async_wait(boost::bind(&http_session::read_timeout, | |
shared_from_this(), | |
boost::asio::placeholders::error)); | |
} | |
} | |
void http_session::read_timeout(const error_code& ec) | |
{ | |
this->end(c_handler_); | |
return; | |
} | |
void http_session::end(CloseHandler c_handler) | |
{ | |
socket_->close(); | |
c_handler(static_cast<boost::shared_ptr<session_base>>(shared_from_this())); | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment