|
@@ -7,6 +7,8 @@
|
|
|
#include <asiolink/asio_wrapper.h>
|
|
|
#include <http/connection.h>
|
|
|
#include <http/connection_pool.h>
|
|
|
+#include <http/http_log.h>
|
|
|
+#include <http/http_messages.h>
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
|
using namespace isc::asiolink;
|
|
@@ -58,8 +60,11 @@ HttpConnection::close() {
|
|
|
void
|
|
|
HttpConnection::stopThisConnection() {
|
|
|
try {
|
|
|
+ LOG_DEBUG(http_logger, DBGLVL_TRACE_BASIC, HTTP_CONNECTION_STOP)
|
|
|
+ .arg(getRemoteEndpointAddressAsText());
|
|
|
connection_pool_.stop(shared_from_this());
|
|
|
} catch (...) {
|
|
|
+ LOG_ERROR(http_logger, HTTP_CONNECTION_STOP_FAILED);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -123,6 +128,9 @@ HttpConnection::acceptorCallback(const boost::system::error_code& ec) {
|
|
|
acceptor_callback_(ec);
|
|
|
|
|
|
if (!ec) {
|
|
|
+ LOG_DEBUG(http_logger, DBGLVL_TRACE_DETAIL, HTTP_REQUEST_RECEIVE_START)
|
|
|
+ .arg(getRemoteEndpointAddressAsText())
|
|
|
+ .arg(static_cast<unsigned>(request_timeout_/1000));
|
|
|
request_timer_.setup(boost::bind(&HttpConnection::requestTimeoutCallback, this),
|
|
|
request_timeout_, IntervalTimer::ONE_SHOT);
|
|
|
doRead();
|
|
@@ -131,6 +139,11 @@ HttpConnection::acceptorCallback(const boost::system::error_code& ec) {
|
|
|
|
|
|
void
|
|
|
HttpConnection::socketReadCallback(boost::system::error_code ec, size_t length) {
|
|
|
+ if (length != 0) {
|
|
|
+ LOG_DEBUG(http_logger, DBGLVL_TRACE_DETAIL_DATA, HTTP_DATA_RECEIVED)
|
|
|
+ .arg(length)
|
|
|
+ .arg(getRemoteEndpointAddressAsText());
|
|
|
+ }
|
|
|
std::string s(&buf_[0], buf_[0] + length);
|
|
|
parser_->postBuffer(static_cast<void*>(buf_.data()), length);
|
|
|
parser_->poll();
|
|
@@ -138,12 +151,17 @@ HttpConnection::socketReadCallback(boost::system::error_code ec, size_t length)
|
|
|
doRead();
|
|
|
|
|
|
} else {
|
|
|
+ LOG_DEBUG(http_logger, DBGLVL_TRACE_DETAIL, HTTP_REQUEST_RECEIVED)
|
|
|
+ .arg(getRemoteEndpointAddressAsText());
|
|
|
try {
|
|
|
request_->finalize();
|
|
|
} catch (...) {
|
|
|
}
|
|
|
|
|
|
HttpResponsePtr response = response_creator_->createHttpResponse(request_);
|
|
|
+ LOG_DEBUG(http_logger, DBGLVL_TRACE_DETAIL, HTTP_RESPONSE_SEND)
|
|
|
+ .arg(response->toBriefString())
|
|
|
+ .arg(getRemoteEndpointAddressAsText());
|
|
|
asyncSendResponse(response);
|
|
|
}
|
|
|
}
|
|
@@ -163,12 +181,25 @@ HttpConnection::socketWriteCallback(boost::system::error_code ec,
|
|
|
|
|
|
void
|
|
|
HttpConnection::requestTimeoutCallback() {
|
|
|
+ LOG_DEBUG(http_logger, DBGLVL_TRACE_DETAIL, HTTP_REQUEST_TIMEOUT_OCCURRED)
|
|
|
+ .arg(getRemoteEndpointAddressAsText());
|
|
|
HttpResponsePtr response =
|
|
|
response_creator_->createStockHttpResponse(request_,
|
|
|
HttpStatusCode::REQUEST_TIMEOUT);
|
|
|
asyncSendResponse(response);
|
|
|
}
|
|
|
|
|
|
+std::string
|
|
|
+HttpConnection::getRemoteEndpointAddressAsText() const {
|
|
|
+ try {
|
|
|
+ if (socket_.getASIOSocket().is_open()) {
|
|
|
+ return (socket_.getASIOSocket().remote_endpoint().address().to_string());
|
|
|
+ }
|
|
|
+ } catch (...) {
|
|
|
+ }
|
|
|
+ return ("(unknown address)");
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
} // end of namespace isc::http
|
|
|
} // end of namespace isc
|