3
0

ServiceJob.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. // The AWS Native SDK AWSAllocator triggers a warning due to accessing members of std::allocator directly.
  9. // AWSAllocator.h(70): warning C4996: 'std::allocator<T>::pointer': warning STL4010: Various members of std::allocator are deprecated in C++17.
  10. // Use std::allocator_traits instead of accessing these members directly.
  11. // You can define _SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
  12. #include <AzCore/PlatformDef.h>
  13. AZ_PUSH_DISABLE_WARNING(4251 4996, "-Wunknown-warning-option")
  14. #include <aws/core/http/HttpRequest.h>
  15. #include <aws/core/http/HttpClientFactory.h>
  16. AZ_POP_DISABLE_WARNING
  17. #include <Framework/RequestBuilder.h>
  18. #include <Framework/ServiceJob.h>
  19. #include <Framework/ServiceJobUtil.h>
  20. namespace AWSCore
  21. {
  22. HttpRequestJob& ServiceJob::GetHttpRequestJob()
  23. {
  24. return *this;
  25. }
  26. const HttpRequestJob& ServiceJob::GetHttpRequestJob() const
  27. {
  28. return *this;
  29. }
  30. void ServiceJob::Start()
  31. {
  32. HttpRequestJob::Start();
  33. }
  34. std::shared_ptr<Aws::Http::HttpRequest> ServiceJob::InitializeRequest()
  35. {
  36. std::shared_ptr<Aws::Http::HttpRequest> request;
  37. RequestBuilder requestBuilder{};
  38. if (BuildRequest(requestBuilder))
  39. {
  40. request = Aws::Http::CreateHttpRequest(
  41. requestBuilder.GetRequestUrl(),
  42. requestBuilder.GetHttpMethod(),
  43. &Aws::Utils::Stream::DefaultResponseStreamFactoryMethod
  44. );
  45. SetAWSAuthSigner(requestBuilder.GetAWSAuthSigner());
  46. AZStd::string bodyString;
  47. if (std::shared_ptr<Aws::StringStream> bodyContent = GetBodyContent(requestBuilder))
  48. {
  49. std::istreambuf_iterator<AZStd::string::value_type> eos;
  50. bodyString = AZStd::string{ std::istreambuf_iterator<AZStd::string::value_type>(*bodyContent), eos };
  51. }
  52. ConfigureJsonServiceRequest(*this, bodyString);
  53. }
  54. return request;
  55. }
  56. std::shared_ptr<Aws::StringStream> ServiceJob::GetBodyContent(RequestBuilder& requestBuilder)
  57. {
  58. return requestBuilder.GetBodyContent();
  59. }
  60. } // namespace AWSCore