diff options
author | Thomas Markwalder <tmark@isc.org> | 2019-06-22 17:38:55 +0200 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2019-06-27 13:49:10 +0200 |
commit | 770aeae623c1c5f046149abeff50458175225731 (patch) | |
tree | 23214c325995636173bd8f6b5c6c58e48703c7d8 /src/lib/http/client.h | |
parent | hammer: fixed handling repos over https (diff) | |
download | kea-770aeae623c1c5f046149abeff50458175225731.tar.xz kea-770aeae623c1c5f046149abeff50458175225731.zip |
[#691,!395] Add Connection socket exposure and close_callback handler
Addes close_callback and exposes Connectin's TCP socket to it
and connect_callback.
src/lib/http/client.h b/src/lib/http/client.h
HttpClient:
Added second parameter, socket FD, to ConnectHandler
Added CloseHandler typedef
asyncSendRequest() - added close_callback parameter
src/lib/http/client.cc
Connection - added close_callback parameter to all
methods that accept connect_callback parameter
Added invocation of close_callback wherever the connection's
socket is closed.
src/lib/http/tests/server_client_unittests.cc
TEST_F(HttpClientTest, connectCloseCallbacks) - new test that
verifies connect and close callback operations
Diffstat (limited to 'src/lib/http/client.h')
-rw-r--r-- | src/lib/http/client.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lib/http/client.h b/src/lib/http/client.h index ac33c9f9a3..46ec5c8615 100644 --- a/src/lib/http/client.h +++ b/src/lib/http/client.h @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -86,9 +86,18 @@ public: /// /// Returned boolean value indicates whether the client should continue /// connecting to the server (if true) or not (false). + /// It is passed the IO error code along with the native socket handle of + /// the connection's TCP socket. This always the socket's event readiness + /// to be monitored via select() or epoll. + /// /// @note Beware that the IO error code can be set to "in progress" /// so a not null error code does not always mean the connect failed. - typedef std::function<bool(const boost::system::error_code&)> ConnectHandler; + typedef std::function<bool(const boost::system::error_code&, const int)> ConnectHandler; + + /// @brief Optional handler invoked when client closes the connection to the server. + /// + /// It is passed the native socket handler of the connection's TCP socket. + typedef std::function<void(const int)> CloseHandler; /// @brief Constructor. /// @@ -167,7 +176,9 @@ public: const RequestTimeout& request_timeout = RequestTimeout(10000), const ConnectHandler& connect_callback = - ConnectHandler()); + ConnectHandler(), + const CloseHandler& close_callback = + CloseHandler()); /// @brief Closes all connections. void stop(); |