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/GetObjectRequest.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 | GetObjectRequest::GetObjectRequest() : |
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_responseCacheControlHasBeenSet(false), |
38 | m_responseContentDispositionHasBeenSet(false), |
39 | m_responseContentEncodingHasBeenSet(false), |
40 | m_responseContentLanguageHasBeenSet(false), |
41 | m_responseContentTypeHasBeenSet(false), |
42 | m_responseExpiresHasBeenSet(false), |
43 | m_versionIdHasBeenSet(false), |
44 | m_sSECustomerAlgorithmHasBeenSet(false), |
45 | m_sSECustomerKeyHasBeenSet(false), |
46 | m_sSECustomerKeyMD5HasBeenSet(false), |
47 | m_requestPayer(RequestPayer::NOT_SET), |
48 | m_requestPayerHasBeenSet(false), |
49 | m_partNumber(0), |
50 | m_partNumberHasBeenSet(false), |
51 | m_customizedAccessLogTagHasBeenSet(false) |
52 | { |
53 | } |
54 | |
55 | Aws::String GetObjectRequest::SerializePayload() const |
56 | { |
57 | return {}; |
58 | } |
59 | |
60 | void GetObjectRequest::AddQueryStringParameters(URI& uri) const |
61 | { |
62 | Aws::StringStream ss; |
63 | if(m_responseCacheControlHasBeenSet) |
64 | { |
65 | ss << m_responseCacheControl; |
66 | uri.AddQueryStringParameter("response-cache-control" , ss.str()); |
67 | ss.str("" ); |
68 | } |
69 | |
70 | if(m_responseContentDispositionHasBeenSet) |
71 | { |
72 | ss << m_responseContentDisposition; |
73 | uri.AddQueryStringParameter("response-content-disposition" , ss.str()); |
74 | ss.str("" ); |
75 | } |
76 | |
77 | if(m_responseContentEncodingHasBeenSet) |
78 | { |
79 | ss << m_responseContentEncoding; |
80 | uri.AddQueryStringParameter("response-content-encoding" , ss.str()); |
81 | ss.str("" ); |
82 | } |
83 | |
84 | if(m_responseContentLanguageHasBeenSet) |
85 | { |
86 | ss << m_responseContentLanguage; |
87 | uri.AddQueryStringParameter("response-content-language" , ss.str()); |
88 | ss.str("" ); |
89 | } |
90 | |
91 | if(m_responseContentTypeHasBeenSet) |
92 | { |
93 | ss << m_responseContentType; |
94 | uri.AddQueryStringParameter("response-content-type" , ss.str()); |
95 | ss.str("" ); |
96 | } |
97 | |
98 | if(m_responseExpiresHasBeenSet) |
99 | { |
100 | ss << m_responseExpires.ToGmtString(DateFormat::RFC822); |
101 | uri.AddQueryStringParameter("response-expires" , ss.str()); |
102 | ss.str("" ); |
103 | } |
104 | |
105 | if(m_versionIdHasBeenSet) |
106 | { |
107 | ss << m_versionId; |
108 | uri.AddQueryStringParameter("versionId" , ss.str()); |
109 | ss.str("" ); |
110 | } |
111 | |
112 | if(m_partNumberHasBeenSet) |
113 | { |
114 | ss << m_partNumber; |
115 | uri.AddQueryStringParameter("partNumber" , ss.str()); |
116 | ss.str("" ); |
117 | } |
118 | |
119 | if(!m_customizedAccessLogTag.empty()) |
120 | { |
121 | // only accept customized LogTag which starts with "x-" |
122 | Aws::Map<Aws::String, Aws::String> collectedLogTags; |
123 | for(const auto& entry: m_customizedAccessLogTag) |
124 | { |
125 | if (!entry.first.empty() && !entry.second.empty() && entry.first.substr(0, 2) == "x-" ) |
126 | { |
127 | collectedLogTags.emplace(entry.first, entry.second); |
128 | } |
129 | } |
130 | |
131 | if (!collectedLogTags.empty()) |
132 | { |
133 | uri.AddQueryStringParameter(collectedLogTags); |
134 | } |
135 | } |
136 | } |
137 | |
138 | Aws::Http::HeaderValueCollection GetObjectRequest::() const |
139 | { |
140 | Aws::Http::HeaderValueCollection ; |
141 | Aws::StringStream ss; |
142 | if(m_ifMatchHasBeenSet) |
143 | { |
144 | ss << m_ifMatch; |
145 | headers.emplace("if-match" , ss.str()); |
146 | ss.str("" ); |
147 | } |
148 | |
149 | if(m_ifModifiedSinceHasBeenSet) |
150 | { |
151 | headers.emplace("if-modified-since" , m_ifModifiedSince.ToGmtString(DateFormat::RFC822)); |
152 | } |
153 | |
154 | if(m_ifNoneMatchHasBeenSet) |
155 | { |
156 | ss << m_ifNoneMatch; |
157 | headers.emplace("if-none-match" , ss.str()); |
158 | ss.str("" ); |
159 | } |
160 | |
161 | if(m_ifUnmodifiedSinceHasBeenSet) |
162 | { |
163 | headers.emplace("if-unmodified-since" , m_ifUnmodifiedSince.ToGmtString(DateFormat::RFC822)); |
164 | } |
165 | |
166 | if(m_rangeHasBeenSet) |
167 | { |
168 | ss << m_range; |
169 | headers.emplace("range" , ss.str()); |
170 | ss.str("" ); |
171 | } |
172 | |
173 | if(m_sSECustomerAlgorithmHasBeenSet) |
174 | { |
175 | ss << m_sSECustomerAlgorithm; |
176 | headers.emplace("x-amz-server-side-encryption-customer-algorithm" , ss.str()); |
177 | ss.str("" ); |
178 | } |
179 | |
180 | if(m_sSECustomerKeyHasBeenSet) |
181 | { |
182 | ss << m_sSECustomerKey; |
183 | headers.emplace("x-amz-server-side-encryption-customer-key" , ss.str()); |
184 | ss.str("" ); |
185 | } |
186 | |
187 | if(m_sSECustomerKeyMD5HasBeenSet) |
188 | { |
189 | ss << m_sSECustomerKeyMD5; |
190 | headers.emplace("x-amz-server-side-encryption-customer-key-md5" , ss.str()); |
191 | ss.str("" ); |
192 | } |
193 | |
194 | if(m_requestPayerHasBeenSet) |
195 | { |
196 | headers.emplace("x-amz-request-payer" , RequestPayerMapper::GetNameForRequestPayer(m_requestPayer)); |
197 | } |
198 | |
199 | return headers; |
200 | } |
201 | |