1/*
2 * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License").
5 * You may not use this file except in compliance with the License.
6 * A copy of the License is located at
7 *
8 * http://aws.amazon.com/apache2.0
9 *
10 * or in the "license" file accompanying this file. This file is distributed
11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12 * express or implied. See the License for the specific language governing
13 * permissions and limitations under the License.
14 */
15
16#include <aws/core/http/HttpClient.h>
17#include <aws/core/http/HttpRequest.h>
18
19using namespace Aws;
20using namespace Aws::Http;
21
22HttpClient::HttpClient() :
23 m_disableRequestProcessing( false ),
24 m_requestProcessingSignalLock(),
25 m_requestProcessingSignal()
26{
27}
28
29void HttpClient::DisableRequestProcessing()
30{
31 m_disableRequestProcessing = true;
32 m_requestProcessingSignal.notify_all();
33}
34
35void HttpClient::EnableRequestProcessing()
36{
37 m_disableRequestProcessing = false;
38}
39
40bool HttpClient::IsRequestProcessingEnabled() const
41{
42 return m_disableRequestProcessing.load() == false;
43}
44
45void HttpClient::RetryRequestSleep(std::chrono::milliseconds sleepTime)
46{
47 std::unique_lock< std::mutex > signalLocker(m_requestProcessingSignalLock);
48 m_requestProcessingSignal.wait_for(signalLocker, sleepTime, [this](){ return m_disableRequestProcessing.load() == true; });
49}
50
51bool HttpClient::ContinueRequest(const Aws::Http::HttpRequest& request) const
52{
53 if (request.GetContinueRequestHandler())
54 {
55 return request.GetContinueRequestHandler()(&request);
56 }
57
58 return true;
59}
60