10 #include <boost/asio.hpp>
11 #include <boost/logic/tribool.hpp>
12 #include <pion/net/HTTPReader.hpp>
13 #include <pion/net/HTTPRequest.hpp>
22 const boost::uint32_t HTTPReader::DEFAULT_READ_TIMEOUT = 10;
29 if (m_tcp_conn->getPipelined()) {
31 m_tcp_conn->setLifecycle(TCPConnection::LIFECYCLE_CLOSE);
36 m_tcp_conn->setLifecycle(TCPConnection::LIFECYCLE_CLOSE);
37 readBytesWithTimeout();
42 std::size_t bytes_read)
46 m_timer_ptr->cancel();
52 handleReadError(read_error);
56 PION_LOG_DEBUG(
m_logger,
"Read " << bytes_read <<
" bytes from HTTP "
60 setReadBuffer(m_tcp_conn->getReadBuffer().data(), bytes_read);
76 boost::system::error_code ec;
91 m_tcp_conn->setLifecycle(TCPConnection::LIFECYCLE_KEEPALIVE);
94 m_tcp_conn->setLifecycle(TCPConnection::LIFECYCLE_PIPELINED);
101 PION_LOG_DEBUG(
m_logger,
"HTTP pipelined "
106 m_tcp_conn->setLifecycle(TCPConnection::LIFECYCLE_CLOSE);
112 }
else if (result ==
false) {
114 m_tcp_conn->setLifecycle(TCPConnection::LIFECYCLE_CLOSE);
119 readBytesWithTimeout();
123 void HTTPReader::readBytesWithTimeout(
void)
125 if (m_read_timeout > 0) {
126 m_timer_ptr.reset(
new TCPTimer(m_tcp_conn));
127 m_timer_ptr->start(m_read_timeout);
128 }
else if (m_timer_ptr) {
134 void HTTPReader::handleReadError(
const boost::system::error_code& read_error)
137 m_tcp_conn->setLifecycle(TCPConnection::LIFECYCLE_CLOSE);
141 boost::system::error_code ec;
148 if (read_error == boost::asio::error::operation_aborted) {
152 <<
" parsing aborted (shutting down)");
155 <<
" parsing aborted (" << read_error.message() <<
')');