diff options
author | Marcin Siodelski <marcin@isc.org> | 2018-11-05 14:12:53 +0100 |
---|---|---|
committer | Tomek Mrugalski <tomasz@isc.org> | 2018-11-07 10:30:21 +0100 |
commit | ba4fe0c9e87c920701b3b15565717f6f00cb324f (patch) | |
tree | 9bf8a43f7cf44a2e3da97240dc511a41216ab38e /src/lib/http/client.h | |
parent | [#61,!114] commit-id updated. (diff) | |
download | kea-ba4fe0c9e87c920701b3b15565717f6f00cb324f.tar.xz kea-ba4fe0c9e87c920701b3b15565717f6f00cb324f.zip |
[#26,!106] Guard HTTP client connect with timeout.
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 5731826ad9..132eda3477 100644 --- a/src/lib/http/client.h +++ b/src/lib/http/client.h @@ -82,6 +82,12 @@ public: const HttpResponsePtr&, const std::string&)> RequestHandler; + /// @brief Optional handler invoked when client connects to the server. + /// + /// Returned boolean value indicates whether the client should continue + /// connecting to the server (if true) or not (false). + typedef std::function<bool(const boost::system::error_code&)> ConnectHandler; + /// @brief Constructor. /// /// @param io_service IO service to be used by the HTTP client. @@ -141,16 +147,21 @@ public: /// @param url URL where the request should be send. /// @param request Pointer to the object holding a request. /// @param response Pointer to the object where response should be stored. - /// @param callback Pointer to the user callback function. + /// @param request_callback Pointer to the user callback function invoked + /// when transaction ends. /// @param request_timeout Timeout for the transaction in milliseconds. + /// @param connect_callback Optional callback invoked when the client + /// connects to the server. /// /// @throw HttpClientError If invalid arguments were provided. void asyncSendRequest(const Url& url, const HttpRequestPtr& request, const HttpResponsePtr& response, - const RequestHandler& callback, + const RequestHandler& request_callback, const RequestTimeout& request_timeout = - RequestTimeout(10000)); + RequestTimeout(10000), + const ConnectHandler& connect_callback = + ConnectHandler()); /// @brief Closes all connections. void stop(); |