1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/core/http/Scheme.h>
7 #include <aws/core/utils/memory/stl/AWSString.h>
8 #include <aws/core/utils/StringUtils.h>
9 
10 using namespace Aws::Http;
11 using namespace Aws::Utils;
12 
13 namespace Aws
14 {
15 namespace Http
16 {
17 namespace SchemeMapper
18 {
19 
ToString(Scheme scheme)20     const char* ToString(Scheme scheme)
21     {
22         switch (scheme)
23         {
24             case Scheme::HTTP:
25                 return "http";
26             case Scheme::HTTPS:
27                 return "https";
28             default:
29                 return "http";
30         }
31     }
32 
FromString(const char * name)33     Scheme FromString(const char* name)
34     {
35         Aws::String trimmedString = StringUtils::Trim(name);
36         Aws::String loweredTrimmedString = StringUtils::ToLower(trimmedString.c_str());
37 
38         if (loweredTrimmedString == "http")
39         {
40             return Scheme::HTTP;
41         }
42         //this branch is technically unneeded, but it is here so we don't have a subtle bug
43         //creep in as we extend this enum.
44         else if (loweredTrimmedString == "https")
45         {
46             return Scheme::HTTPS;
47         }
48 
49         return Scheme::HTTPS;
50     }
51 
52 } // namespace SchemeMapper
53 } // namespace Http
54 } // namespace Aws
55