From ba4fe0c9e87c920701b3b15565717f6f00cb324f Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Mon, 5 Nov 2018 14:12:53 +0100 Subject: [#26,!106] Guard HTTP client connect with timeout. --- src/lib/http/client.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/lib/http/client.h') 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 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(); -- cgit v1.2.3