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/s3/model/HeadObjectRequest.h> |
17 | #include <aws/core/utils/xml/XmlSerializer.h> |
18 | #include <aws/core/utils/memory/stl/AWSStringStream.h> |
19 | #include <aws/core/http/URI.h> |
20 | #include <aws/core/utils/memory/stl/AWSStringStream.h> |
21 | |
22 | #include <utility> |
23 | |
24 | using namespace Aws::S3::Model; |
25 | using namespace Aws::Utils::Xml; |
26 | using namespace Aws::Utils; |
27 | using namespace Aws::Http; |
28 | |
29 | HeadObjectRequest::HeadObjectRequest() : |
30 | m_bucketHasBeenSet(false), |
31 | m_ifMatchHasBeenSet(false), |
32 | m_ifModifiedSinceHasBeenSet(false), |
33 | m_ifNoneMatchHasBeenSet(false), |
34 | m_ifUnmodifiedSinceHasBeenSet(false), |
35 | m_keyHasBeenSet(false), |
36 | m_rangeHasBeenSet(false), |
37 | m_versionIdHasBeenSet(false), |
38 | m_sSECustomerAlgorithmHasBeenSet(false), |
39 | m_sSECustomerKeyHasBeenSet(false), |
40 | m_sSECustomerKeyMD5HasBeenSet(false), |
41 | m_requestPayer(RequestPayer::NOT_SET), |
42 | m_requestPayerHasBeenSet(false), |
43 | m_partNumber(0), |
44 | m_partNumberHasBeenSet(false), |
45 | m_customizedAccessLogTagHasBeenSet(false) |
46 | { |
47 | } |
48 | |
49 | Aws::String HeadObjectRequest::SerializePayload() const |
50 | { |
51 | return {}; |
52 | } |
53 | |
54 | void HeadObjectRequest::AddQueryStringParameters(URI& uri) const |
55 | { |
56 | Aws::StringStream ss; |
57 | if(m_versionIdHasBeenSet) |
58 | { |
59 | ss << m_versionId; |
60 | uri.AddQueryStringParameter("versionId" , ss.str()); |
61 | ss.str("" ); |
62 | } |
63 | |
64 | if(m_partNumberHasBeenSet) |
65 | { |
66 | ss << m_partNumber; |
67 | uri.AddQueryStringParameter("partNumber" , ss.str()); |
68 | ss.str("" ); |
69 | } |
70 | |
71 | if(!m_customizedAccessLogTag.empty()) |
72 | { |
73 | // only accept customized LogTag which starts with "x-" |
74 | Aws::Map<Aws::String, Aws::String> collectedLogTags; |
75 | for(const auto& entry: m_customizedAccessLogTag) |
76 | { |
77 | if (!entry.first.empty() && !entry.second.empty() && entry.first.substr(0, 2) == "x-" ) |
78 | { |
79 | collectedLogTags.emplace(entry.first, entry.second); |
80 | } |
81 | } |
82 | |
83 | if (!collectedLogTags.empty()) |
84 | { |
85 | uri.AddQueryStringParameter(collectedLogTags); |
86 | } |
87 | } |
88 | } |
89 | |
90 | Aws::Http::HeaderValueCollection HeadObjectRequest::() const |
91 | { |
92 | Aws::Http::HeaderValueCollection ; |
93 | Aws::StringStream ss; |
94 | if(m_ifMatchHasBeenSet) |
95 | { |
96 | ss << m_ifMatch; |
97 | headers.emplace("if-match" , ss.str()); |
98 | ss.str("" ); |
99 | } |
100 | |
101 | if(m_ifModifiedSinceHasBeenSet) |
102 | { |
103 | headers.emplace("if-modified-since" , m_ifModifiedSince.ToGmtString(DateFormat::RFC822)); |
104 | } |
105 | |
106 | if(m_ifNoneMatchHasBeenSet) |
107 | { |
108 | ss << m_ifNoneMatch; |
109 | headers.emplace("if-none-match" , ss.str()); |
110 | ss.str("" ); |
111 | } |
112 | |
113 | if(m_ifUnmodifiedSinceHasBeenSet) |
114 | { |
115 | headers.emplace("if-unmodified-since" , m_ifUnmodifiedSince.ToGmtString(DateFormat::RFC822)); |
116 | } |
117 | |
118 | if(m_rangeHasBeenSet) |
119 | { |
120 | ss << m_range; |
121 | headers.emplace("range" , ss.str()); |
122 | ss.str("" ); |
123 | } |
124 | |
125 | if(m_sSECustomerAlgorithmHasBeenSet) |
126 | { |
127 | ss << m_sSECustomerAlgorithm; |
128 | headers.emplace("x-amz-server-side-encryption-customer-algorithm" , ss.str()); |
129 | ss.str("" ); |
130 | } |
131 | |
132 | if(m_sSECustomerKeyHasBeenSet) |
133 | { |
134 | ss << m_sSECustomerKey; |
135 | headers.emplace("x-amz-server-side-encryption-customer-key" , ss.str()); |
136 | ss.str("" ); |
137 | } |
138 | |
139 | if(m_sSECustomerKeyMD5HasBeenSet) |
140 | { |
141 | ss << m_sSECustomerKeyMD5; |
142 | headers.emplace("x-amz-server-side-encryption-customer-key-md5" , ss.str()); |
143 | ss.str("" ); |
144 | } |
145 | |
146 | if(m_requestPayerHasBeenSet) |
147 | { |
148 | headers.emplace("x-amz-request-payer" , RequestPayerMapper::GetNameForRequestPayer(m_requestPayer)); |
149 | } |
150 | |
151 | return headers; |
152 | } |
153 | |