/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include #include #include #include #include namespace Aws { namespace Utils { namespace RateLimits { class RateLimiterInterface; } // namespace RateLimits } // namespace Utils namespace Http { class HttpRequest; class HttpResponse; /** * Abstract HttpClient. All it does is make HttpRequests and return their response. */ class AWS_CORE_API HttpClient { public: HttpClient(); virtual ~HttpClient() {} /** * Takes an http request, makes it, and returns the newly allocated HttpResponse. */ virtual std::shared_ptr MakeRequest(const std::shared_ptr& request, Aws::Utils::RateLimits::RateLimiterInterface* readLimiter = nullptr, Aws::Utils::RateLimits::RateLimiterInterface* writeLimiter = nullptr) const = 0; /** * If yes, the http client supports transfer-encoding:chunked. */ virtual bool SupportsChunkedTransferEncoding() const { return true; } /** * Stops all requests in progress and prevents any others from initiating. */ void DisableRequestProcessing(); /** * Enables/ReEnables request processing. */ void EnableRequestProcessing(); /** * Returns true if request processing is enabled. */ bool IsRequestProcessingEnabled() const; /** * Sleeps current thread for sleepTime. */ void RetryRequestSleep(std::chrono::milliseconds sleepTime); bool ContinueRequest(const Aws::Http::HttpRequest&) const; private: std::atomic< bool > m_disableRequestProcessing; std::mutex m_requestProcessingSignalLock; std::condition_variable m_requestProcessingSignal; }; } // namespace Http } // namespace Aws