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