aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/endpoint/AWSEndpoint.cpp
blob: 4990faff2439b5ec992cfa3e5180447f0c884a38 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

#include <aws/core/endpoint/AWSEndpoint.h>
#include <aws/core/utils/DNS.h>

namespace Aws
{
namespace Endpoint
{

Aws::String AWSEndpoint::GetURL() const
{
    return m_uri.GetURIString();
}

void AWSEndpoint::SetURL(Aws::String url)
{
    m_uri = std::move(url);
}

const Aws::Http::URI& AWSEndpoint::GetURI() const
{
    return m_uri;
}

void AWSEndpoint::SetURI(Aws::Http::URI uri)
{
    m_uri = std::move(uri);
}

AWSEndpoint::OptionalError AWSEndpoint::AddPrefixIfMissing(const Aws::String& prefix)
{
    if (m_uri.GetAuthority().rfind(prefix, 0) == 0)
    {
        // uri already starts with a prefix
        return OptionalError();
    }

    if (Aws::Utils::IsValidHost(prefix + m_uri.GetAuthority()))
    {
        m_uri.SetAuthority(prefix + m_uri.GetAuthority());
        return OptionalError();
    }

    return OptionalError(
        Aws::Client::AWSError<Aws::Client::CoreErrors>(
            Aws::Client::CoreErrors::ENDPOINT_RESOLUTION_FAILURE, "",
            Aws::String("Failed to add host prefix, resulting uri is an invalid hostname: ") + prefix + m_uri.GetAuthority(),
            false/*retryable*/));
}

void AWSEndpoint::SetQueryString(const Aws::String& queryString)
{
    m_uri.SetQueryString(queryString);
}

const Crt::Optional<AWSEndpoint::EndpointAttributes>& AWSEndpoint::GetAttributes() const
{
    return m_attributes;
}

Crt::Optional<AWSEndpoint::EndpointAttributes>& AWSEndpoint::AccessAttributes()
{
    return m_attributes;
}

void AWSEndpoint::SetAttributes(AWSEndpoint::EndpointAttributes&& attributes)
{
    m_attributes = std::move(attributes);
}

const Aws::UnorderedMap<Aws::String, Aws::String>& AWSEndpoint::GetHeaders() const
{
    return m_headers;
}

void AWSEndpoint::SetHeaders(Aws::UnorderedMap<Aws::String, Aws::String> headers)
{
    m_headers = std::move(headers);
}

} // namespace Endpoint
} // namespace Aws