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/Scheme.h> |
17 | #include <aws/core/utils/memory/stl/AWSString.h> |
18 | #include <aws/core/utils/StringUtils.h> |
19 | |
20 | using namespace Aws::Http; |
21 | using namespace Aws::Utils; |
22 | |
23 | namespace Aws |
24 | { |
25 | namespace Http |
26 | { |
27 | namespace SchemeMapper |
28 | { |
29 | |
30 | const char* ToString(Scheme scheme) |
31 | { |
32 | switch (scheme) |
33 | { |
34 | case Scheme::HTTP: |
35 | return "http" ; |
36 | case Scheme::HTTPS: |
37 | return "https" ; |
38 | default: |
39 | return "http" ; |
40 | } |
41 | } |
42 | |
43 | Scheme FromString(const char* name) |
44 | { |
45 | Aws::String trimmedString = StringUtils::Trim(name); |
46 | Aws::String loweredTrimmedString = StringUtils::ToLower(trimmedString.c_str()); |
47 | |
48 | if (loweredTrimmedString == "http" ) |
49 | { |
50 | return Scheme::HTTP; |
51 | } |
52 | //this branch is technically unneeded, but it is here so we don't have a subtle bug |
53 | //creep in as we extend this enum. |
54 | else if (loweredTrimmedString == "https" ) |
55 | { |
56 | return Scheme::HTTPS; |
57 | } |
58 | |
59 | return Scheme::HTTPS; |
60 | } |
61 | |
62 | } // namespace SchemeMapper |
63 | } // namespace Http |
64 | } // namespace Aws |
65 | |