/// @brief Constructor.
///
/// @param io_service IO service to be used for the connection.
- /// @param context TLS context to be used for the connection.
+ /// @param tls_context TLS context to be used for the connection.
/// @param conn_pool Back pointer to the connection pool to which this
/// connection belongs.
/// @param url URL associated with this connection.
explicit Connection(IOService& io_service,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
const ConnectionPoolPtr& conn_pool,
const Url& url);
/// in progress for the given URL. Otherwise, the request is queued.
///
/// @param url Destination where the request should be sent.
- /// @param context TLS context to be used for the connection.
+ /// @param tls_context TLS context to be used for the connection.
/// @param request Pointer to the request to be sent to the server.
/// @param response Pointer to the object into which the response should be
/// stored.
/// @param close_callback Pointer to the user callback to be invoked when the
/// client closes the connection to the server.
void queueRequest(const Url& url,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
const HttpRequestPtr& request,
const HttpResponsePtr& response,
const long request_timeout,
const HttpClient::CloseHandler& close_callback) {
if (MultiThreadingMgr::instance().getMode()) {
std::lock_guard<std::mutex> lk(mutex_);
- return (queueRequestInternal(url, context, request, response,
+ return (queueRequestInternal(url, tls_context, request, response,
request_timeout, request_callback,
connect_callback, handshake_callback,
close_callback));
} else {
- return (queueRequestInternal(url, context, request, response,
+ return (queueRequestInternal(url, tls_context, request, response,
request_timeout, request_callback,
connect_callback, handshake_callback,
close_callback));
/// This method should be called in a thread safe context.
///
/// @param url Destination where the request should be sent.
- /// @param context TLS context to be used for the connection.
+ /// @param tls_context TLS context to be used for the connection.
/// @param request Pointer to the request to be sent to the server.
/// @param response Pointer to the object into which the response should be
/// stored.
/// @param close_callback Pointer to the user callback to be invoked when the
/// client closes the connection to the server.
void queueRequestInternal(const Url& url,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
const HttpRequestPtr& request,
const HttpResponsePtr& response,
const long request_timeout,
// There is no connection with this destination yet. Let's create
// it and start the transaction.
ConnectionPtr conn(new Connection(io_service_,
- context,
+ tls_context,
shared_from_this(),
url));
conn->doTransaction(request, response, request_timeout,
};
Connection::Connection(IOService& io_service,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
const ConnectionPoolPtr& conn_pool,
const Url& url)
: conn_pool_(conn_pool), url_(url), tcp_socket_(), tls_socket_(),
timer_(io_service), current_request_(), current_response_(),
parser_(), current_callback_(), buf_(), input_buf_(),
current_transid_(0), close_callback_(), started_(false) {
- if (!context) {
+ if (!tls_context) {
tcp_socket_.reset(new asiolink::TCPSocket<SocketCallback>(io_service));
} else {
tls_socket_.reset(new asiolink::TLSSocket<SocketCallback>(io_service,
- context));
+ tls_context));
}
}
void
HttpClient::asyncSendRequest(const Url& url,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
const HttpRequestPtr& request,
const HttpResponsePtr& response,
const HttpClient::RequestHandler& request_callback,
isc_throw(HttpClientError, "invalid URL specified for the HTTP client");
}
- if ((url.getScheme() == Url::Scheme::HTTPS) && !context) {
+ if ((url.getScheme() == Url::Scheme::HTTPS) && !tls_context) {
isc_throw(HttpClientError, "HTTPS URL scheme but no TLS context");
}
isc_throw(HttpClientError, "callback for HTTP transaction must not be null");
}
- impl_->conn_pool_->queueRequest(url, context, request, response,
+ impl_->conn_pool_->queueRequest(url, tls_context, request, response,
request_timeout.value_,
request_callback, connect_callback,
handshake_callback, close_callback);
/// callback can be used to recognize this condition.
///
/// @param url URL where the request should be send.
- /// @param context TLS context.
+ /// @param tls_context TLS context.
/// @param request Pointer to the object holding a request.
/// @param response Pointer to the object where response should be stored.
/// @param request_callback Pointer to the user callback function invoked
///
/// @throw HttpClientError If invalid arguments were provided.
void asyncSendRequest(const Url& url,
- const asiolink::TlsContextPtr& context,
+ const asiolink::TlsContextPtr& tls_context,
const HttpRequestPtr& request,
const HttpResponsePtr& response,
const RequestHandler& request_callback,
HttpConnection::HttpConnection(asiolink::IOService& io_service,
const HttpAcceptorPtr& acceptor,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
HttpConnectionPool& connection_pool,
const HttpResponseCreatorPtr& response_creator,
const HttpAcceptorCallback& acceptor_callback,
const long idle_timeout)
: request_timer_(io_service),
request_timeout_(request_timeout),
- context_(context),
+ tls_context_(tls_context),
idle_timeout_(idle_timeout),
tcp_socket_(),
tls_socket_(),
response_creator_(response_creator),
acceptor_callback_(acceptor_callback),
handshake_callback_(handshake_callback) {
- if (!context) {
+ if (!tls_context) {
tcp_socket_.reset(new asiolink::TCPSocket<SocketCallback>(io_service));
} else {
tls_socket_.reset(new asiolink::TLSSocket<SocketCallback>(io_service,
- context));
+ tls_context));
}
}
// Create instance of the callback to close the socket.
SocketCallback cb(std::bind(&HttpConnection::shutdownCallback,
shared_from_this(),
- ph::_1)); // error
+ ph::_1)); // error_code
tls_socket_->shutdown(cb);
return;
}
acceptor_callback_(ec);
if (!ec) {
- if (!context_) {
+ if (!tls_context_) {
LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_DETAIL,
HTTP_REQUEST_RECEIVE_START)
.arg(getRemoteEndpointAddressAsText())
/// @param io_service IO service to be used by the connection.
/// @param acceptor Pointer to the TCP acceptor object used to listen for
/// new HTTP connections.
- /// @param context TLS context.
+ /// @param tls_context TLS context.
/// @param connection_pool Connection pool in which this connection is
/// stored.
/// @param response_creator Pointer to the response creator object used to
/// closed by the server.
HttpConnection(asiolink::IOService& io_service,
const HttpAcceptorPtr& acceptor,
- const asiolink::TlsContextPtr& context,
+ const asiolink::TlsContextPtr& tls_context,
HttpConnectionPool& connection_pool,
const HttpResponseCreatorPtr& response_creator,
const HttpAcceptorCallback& acceptor_callback,
long request_timeout_;
/// @brief TLS context.
- asiolink::TlsContextPtr context_;
+ asiolink::TlsContextPtr tls_context_;
/// @brief Timeout after which the persistent HTTP connection is shut
/// down by the server.
/// @param connection Pointer to the new connection.
void start(const HttpConnectionPtr& connection);
- /// @brief Removes a connection them from the pool and shutdown it.
+ /// @brief Removes a connection from the pool and shutdown it.
///
/// @note if the TLS connection stalls e.g. the peer does not try I/O
/// on it the connection has to be explicitly stopped.
HttpListener::HttpListener(IOService& io_service,
const asiolink::IOAddress& server_address,
const unsigned short server_port,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
const HttpResponseCreatorFactoryPtr& creator_factory,
const HttpListener::RequestTimeout& request_timeout,
const HttpListener::IdleTimeout& idle_timeout)
: impl_(new HttpListenerImpl(io_service, server_address, server_port,
- context, creator_factory,
+ tls_context, creator_factory,
request_timeout.value_,
idle_timeout.value_)) {
}
/// @param io_service IO service to be used by the listener.
/// @param server_address Address on which the HTTP service should run.
/// @param server_port Port number on which the HTTP service should run.
- /// @param context TLS context.
+ /// @param tls_context TLS context.
/// @param creator_factory Pointer to the caller-defined
/// @ref HttpResponseCreatorFactory derivation which should be used to
/// create @ref HttpResponseCreator instances.
HttpListener(asiolink::IOService& io_service,
const asiolink::IOAddress& server_address,
const unsigned short server_port,
- const asiolink::TlsContextPtr& context,
+ const asiolink::TlsContextPtr& tls_context,
const HttpResponseCreatorFactoryPtr& creator_factory,
const RequestTimeout& request_timeout,
const IdleTimeout& idle_timeout);
HttpListenerImpl::HttpListenerImpl(IOService& io_service,
const asiolink::IOAddress& server_address,
const unsigned short server_port,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
const HttpResponseCreatorFactoryPtr& creator_factory,
const long request_timeout,
const long idle_timeout)
- : io_service_(io_service), context_(context), acceptor_(),
+ : io_service_(io_service), tls_context_(tls_context), acceptor_(),
endpoint_(), connections_(),
creator_factory_(creator_factory),
request_timeout_(request_timeout), idle_timeout_(idle_timeout) {
// Create the TCP or TLS acceptor.
- if (!context) {
+ if (!tls_context) {
acceptor_.reset(new HttpAcceptor(io_service));
} else {
acceptor_.reset(new HttpsAcceptor(io_service));
const HttpAcceptorCallback& acceptor_callback,
const HttpAcceptorCallback& handshake_callback) {
HttpConnectionPtr
- conn(new HttpConnection(io_service_, acceptor_, context_,
+ conn(new HttpConnection(io_service_, acceptor_, tls_context_,
connections_, response_creator,
acceptor_callback, handshake_callback,
request_timeout_, idle_timeout_));
/// @param io_service IO service to be used by the listener.
/// @param server_address Address on which the HTTP service should run.
/// @param server_port Port number on which the HTTP service should run.
- /// @param context TLS context.
+ /// @param tls_context TLS context.
/// @param creator_factory Pointer to the caller-defined
/// @ref HttpResponseCreatorFactory derivation which should be used to
/// create @ref HttpResponseCreator instances.
HttpListenerImpl(asiolink::IOService& io_service,
const asiolink::IOAddress& server_address,
const unsigned short server_port,
- const asiolink::TlsContextPtr& context,
+ const asiolink::TlsContextPtr& tls_context,
const HttpResponseCreatorFactoryPtr& creator_factory,
const long request_timeout,
const long idle_timeout);
asiolink::IOService& io_service_;
/// @brief TLS context.
- asiolink::TlsContextPtr context_;
+ asiolink::TlsContextPtr tls_context_;
/// @brief Acceptor instance.
HttpAcceptorPtr acceptor_;
HttpListenerImplCustom(IOService& io_service,
const IOAddress& server_address,
const unsigned short server_port,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
const HttpResponseCreatorFactoryPtr& creator_factory,
const long request_timeout,
const long idle_timeout)
: HttpListenerImpl(io_service, server_address, server_port,
- context, creator_factory, request_timeout,
+ tls_context, creator_factory, request_timeout,
idle_timeout) {
}
/// @param io_service IO service to be used by the connection.
/// @param acceptor Pointer to the TCP acceptor object used to listen for
/// new HTTP connections.
- /// @param context TLS context.
+ /// @param tls_context TLS context.
/// @param connection_pool Connection pool in which this connection is
/// stored.
/// @param response_creator Pointer to the response creator object used to
const HttpAcceptorCallback& handshake_callback) {
HttpConnectionPtr
conn(new HttpConnectionType(io_service_, acceptor_,
- context_, connections_,
+ tls_context_, connections_,
response_creator,
acceptor_callback, handshake_callback,
request_timeout_, idle_timeout_));
/// @param io_service IO service to be used by the listener.
/// @param server_address Address on which the HTTP service should run.
/// @param server_port Port number on which the HTTP service should run.
- /// @param context TLS context.
+ /// @param tls_context TLS context.
/// @param creator_factory Pointer to the caller-defined
/// @ref HttpResponseCreatorFactory derivation which should be used to
/// create @ref HttpResponseCreator instances.
HttpListenerCustom(IOService& io_service,
const IOAddress& server_address,
const unsigned short server_port,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
const HttpResponseCreatorFactoryPtr& creator_factory,
const HttpListener::RequestTimeout& request_timeout,
const HttpListener::IdleTimeout& idle_timeout)
: HttpListener(io_service, server_address, server_port,
- context, creator_factory,
+ tls_context, creator_factory,
request_timeout, idle_timeout) {
// Replace the default implementation with the customized version
// using the custom derivation of the HttpConnection.
impl_.reset(new HttpListenerImplCustom<HttpConnectionType>
(io_service, server_address, server_port,
- context, creator_factory, request_timeout.value_,
+ tls_context, creator_factory, request_timeout.value_,
idle_timeout.value_));
}
};
/// @param io_service IO service to be used by the connection.
/// @param acceptor Pointer to the TCP acceptor object used to listen for
/// new HTTP connections.
- /// @param context TLS context.
+ /// @param tls_context TLS context.
/// @param connection_pool Connection pool in which this connection is
/// stored.
/// @param response_creator Pointer to the response creator object used to
/// closed by the server.
HttpConnectionLongWriteBuffer(IOService& io_service,
const HttpAcceptorPtr& acceptor,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
HttpConnectionPool& connection_pool,
const HttpResponseCreatorPtr& response_creator,
const HttpAcceptorCallback& acceptor_callback,
const HttpAcceptorCallback& handshake_callback,
const long request_timeout,
const long idle_timeout)
- : HttpConnection(io_service, acceptor, context, connection_pool,
+ : HttpConnection(io_service, acceptor, tls_context, connection_pool,
response_creator, acceptor_callback,
handshake_callback, request_timeout,
idle_timeout) {
/// @param io_service IO service to be used by the connection.
/// @param acceptor Pointer to the TCP acceptor object used to listen for
/// new HTTP connections.
- /// @param context TLS context.
+ /// @param context TLS tls_context.
/// @param connection_pool Connection pool in which this connection is
/// stored.
/// @param response_creator Pointer to the response creator object used to
/// closed by the server.
HttpConnectionTransactionChange(IOService& io_service,
const HttpAcceptorPtr& acceptor,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
HttpConnectionPool& connection_pool,
const HttpResponseCreatorPtr& response_creator,
const HttpAcceptorCallback& acceptor_callback,
const HttpAcceptorCallback& handshake_callback,
const long request_timeout,
const long idle_timeout)
- : HttpConnection(io_service, acceptor, context, connection_pool,
+ : HttpConnection(io_service, acceptor, tls_context, connection_pool,
response_creator, acceptor_callback,
handshake_callback, request_timeout,
idle_timeout) {
using namespace isc::util;
namespace ph = std::placeholders;
+/// @todo: put the common part of client and server tests in its own file(s).
+
namespace {
/// @brief IP address to which HTTP service is bound.
using namespace isc::util;
namespace ph = std::placeholders;
+/// @todo: put the common part of client and server tests in its own file(s).
+
namespace {
/// @brief IP address to which HTTP service is bound.
HttpListenerImplCustom(IOService& io_service,
const IOAddress& server_address,
const unsigned short server_port,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
const HttpResponseCreatorFactoryPtr& creator_factory,
const long request_timeout,
const long idle_timeout)
: HttpListenerImpl(io_service, server_address, server_port,
- context, creator_factory, request_timeout,
+ tls_context, creator_factory, request_timeout,
idle_timeout) {
}
/// @param io_service IO service to be used by the connection.
/// @param acceptor Pointer to the TCP acceptor object used to listen for
/// new HTTP connections.
- /// @param context TLS context.
+ /// @param tls_context TLS context.
/// @param connection_pool Connection pool in which this connection is
/// stored.
/// @param response_creator Pointer to the response creator object used to
virtual HttpConnectionPtr createConnection(const HttpResponseCreatorPtr& response_creator,
const HttpAcceptorCallback& acceptor_callback,
const HttpAcceptorCallback& handshake_callback) {
- TlsContextPtr context;
- configClient(context);
+ TlsContextPtr tls_context;
+ configClient(tls_context);
HttpConnectionPtr
conn(new HttpConnectionType(io_service_, acceptor_,
- context_, connections_,
+ tls_context_, connections_,
response_creator,
acceptor_callback, handshake_callback,
request_timeout_, idle_timeout_));
/// @param io_service IO service to be used by the listener.
/// @param server_address Address on which the HTTP service should run.
/// @param server_port Port number on which the HTTP service should run.
- /// @param context TLS context.
+ /// @param tls_context TLS context.
/// @param creator_factory Pointer to the caller-defined
/// @ref HttpResponseCreatorFactory derivation which should be used to
/// create @ref HttpResponseCreator instances.
HttpListenerCustom(IOService& io_service,
const IOAddress& server_address,
const unsigned short server_port,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
const HttpResponseCreatorFactoryPtr& creator_factory,
const HttpListener::RequestTimeout& request_timeout,
const HttpListener::IdleTimeout& idle_timeout)
: HttpListener(io_service, server_address, server_port,
- context, creator_factory,
+ tls_context, creator_factory,
request_timeout, idle_timeout) {
// Replace the default implementation with the customized version
// using the custom derivation of the HttpConnection.
impl_.reset(new HttpListenerImplCustom<HttpConnectionType>
(io_service, server_address, server_port,
- context, creator_factory, request_timeout.value_,
+ tls_context, creator_factory, request_timeout.value_,
idle_timeout.value_));
}
};
/// @param io_service IO service to be used by the connection.
/// @param acceptor Pointer to the TCP acceptor object used to listen for
/// new HTTP connections.
- /// @param context TLS context.
+ /// @param tls_context TLS context.
/// @param connection_pool Connection pool in which this connection is
/// stored.
/// @param response_creator Pointer to the response creator object used to
/// closed by the server.
HttpConnectionLongWriteBuffer(IOService& io_service,
const HttpAcceptorPtr& acceptor,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
HttpConnectionPool& connection_pool,
const HttpResponseCreatorPtr& response_creator,
const HttpAcceptorCallback& acceptor_callback,
const HttpAcceptorCallback& handshake_callback,
const long request_timeout,
const long idle_timeout)
- : HttpConnection(io_service, acceptor, context, connection_pool,
+ : HttpConnection(io_service, acceptor, tls_context, connection_pool,
response_creator, acceptor_callback,
handshake_callback, request_timeout,
idle_timeout) {
/// @param io_service IO service to be used by the connection.
/// @param acceptor Pointer to the TCP acceptor object used to listen for
/// new HTTP connections.
- /// @param context TLS context.
+ /// @param tls_context TLS context.
/// @param connection_pool Connection pool in which this connection is
/// stored.
/// @param response_creator Pointer to the response creator object used to
/// closed by the server.
HttpConnectionTransactionChange(IOService& io_service,
const HttpAcceptorPtr& acceptor,
- const TlsContextPtr& context,
+ const TlsContextPtr& tls_context,
HttpConnectionPool& connection_pool,
const HttpResponseCreatorPtr& response_creator,
const HttpAcceptorCallback& acceptor_callback,
const HttpAcceptorCallback& handshake_callback,
const long request_timeout,
const long idle_timeout)
- : HttpConnection(io_service, acceptor, context, connection_pool,
+ : HttpConnection(io_service, acceptor, tls_context, connection_pool,
response_creator, acceptor_callback,
handshake_callback, request_timeout,
idle_timeout) {
/// connect() to connect to the server.
///
/// @param io_service IO service to be stopped on error.
- /// @param context TLS context.
- TestHttpClient(IOService& io_service, TlsContextPtr context)
+ /// @param tls_context TLS context.
+ TestHttpClient(IOService& io_service, TlsContextPtr tls_context)
: io_service_(io_service.get_io_service()),
- stream_(io_service_, context->getContext()),
+ stream_(io_service_, tls_context->getContext()),
buf_(), response_() {
}