1#[derive(::std::clone::Clone, ::std::default::Default, ::std::fmt::Debug)]
4#[non_exhaustive]
5pub struct GetObject;
6impl GetObject {
7 pub fn new() -> Self {
9 Self
10 }
11 pub(crate) async fn orchestrate(
12 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
13 input: crate::operation::get_object::GetObjectInput,
14 ) -> ::std::result::Result<
15 crate::operation::get_object::GetObjectOutput,
16 ::aws_smithy_runtime_api::client::result::SdkError<
17 crate::operation::get_object::GetObjectError,
18 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
19 >,
20 > {
21 let map_err = |err: ::aws_smithy_runtime_api::client::result::SdkError<
22 ::aws_smithy_runtime_api::client::interceptors::context::Error,
23 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
24 >| {
25 err.map_service_error(|err| {
26 err.downcast::<crate::operation::get_object::GetObjectError>()
27 .expect("correct error type")
28 })
29 };
30 let context = Self::orchestrate_with_stop_point(runtime_plugins, input, ::aws_smithy_runtime::client::orchestrator::StopPoint::None)
31 .await
32 .map_err(map_err)?;
33 let output = context.finalize().map_err(map_err)?;
34 ::std::result::Result::Ok(
35 output
36 .downcast::<crate::operation::get_object::GetObjectOutput>()
37 .expect("correct output type"),
38 )
39 }
40
41 pub(crate) async fn orchestrate_with_stop_point(
42 runtime_plugins: &::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
43 input: crate::operation::get_object::GetObjectInput,
44 stop_point: ::aws_smithy_runtime::client::orchestrator::StopPoint,
45 ) -> ::std::result::Result<
46 ::aws_smithy_runtime_api::client::interceptors::context::InterceptorContext,
47 ::aws_smithy_runtime_api::client::result::SdkError<
48 ::aws_smithy_runtime_api::client::interceptors::context::Error,
49 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
50 >,
51 > {
52 let input = ::aws_smithy_runtime_api::client::interceptors::context::Input::erase(input);
53 use ::tracing::Instrument;
54 ::aws_smithy_runtime::client::orchestrator::invoke_with_stop_point("S3", "GetObject", input, runtime_plugins, stop_point)
55 .instrument(::tracing::debug_span!(
58 "S3.GetObject",
59 "rpc.service" = "S3",
60 "rpc.method" = "GetObject",
61 "sdk_invocation_id" = ::fastrand::u32(1_000_000..10_000_000),
62 "rpc.system" = "aws-api",
63 ))
64 .await
65 }
66
67 pub(crate) fn operation_runtime_plugins(
68 client_runtime_plugins: ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins,
69 client_config: &crate::config::Config,
70 config_override: ::std::option::Option<crate::config::Builder>,
71 ) -> ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugins {
72 let mut runtime_plugins = client_runtime_plugins.with_operation_plugin(Self::new());
73
74 if let ::std::option::Option::Some(config_override) = config_override {
75 for plugin in config_override.runtime_plugins.iter().cloned() {
76 runtime_plugins = runtime_plugins.with_operation_plugin(plugin);
77 }
78 runtime_plugins = runtime_plugins.with_operation_plugin(crate::config::ConfigOverrideRuntimePlugin::new(
79 config_override,
80 client_config.config.clone(),
81 &client_config.runtime_components,
82 ));
83 }
84 runtime_plugins
85 }
86}
87impl ::aws_smithy_runtime_api::client::runtime_plugin::RuntimePlugin for GetObject {
88 fn config(&self) -> ::std::option::Option<::aws_smithy_types::config_bag::FrozenLayer> {
89 let mut cfg = ::aws_smithy_types::config_bag::Layer::new("GetObject");
90
91 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedRequestSerializer::new(
92 GetObjectRequestSerializer,
93 ));
94 cfg.store_put(::aws_smithy_runtime_api::client::ser_de::SharedResponseDeserializer::new(
95 GetObjectResponseDeserializer,
96 ));
97
98 cfg.store_put(::aws_smithy_runtime_api::client::auth::AuthSchemeOptionResolverParams::new(
99 crate::config::auth::Params::builder()
100 .operation_name("GetObject")
101 .build()
102 .expect("required fields set"),
103 ));
104
105 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::SensitiveOutput);
106 cfg.store_put(::aws_smithy_runtime_api::client::orchestrator::Metadata::new("GetObject", "S3"));
107 let mut signing_options = ::aws_runtime::auth::SigningOptions::default();
108 signing_options.double_uri_encode = false;
109 signing_options.content_sha256_header = true;
110 signing_options.normalize_uri_path = false;
111 signing_options.payload_override = None;
112
113 cfg.store_put(::aws_runtime::auth::SigV4OperationSigningConfig {
114 signing_options,
115 ..::std::default::Default::default()
116 });
117
118 ::std::option::Option::Some(cfg.freeze())
119 }
120
121 fn runtime_components(
122 &self,
123 _: &::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder,
124 ) -> ::std::borrow::Cow<'_, ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder> {
125 #[allow(unused_mut)]
126 let mut rcb = ::aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder::new("GetObject")
127 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
128 GetObjectTelemetryInputCaptureInterceptor,
129 ))
130 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
131 ::aws_smithy_runtime::client::stalled_stream_protection::StalledStreamProtectionInterceptor::default(),
132 ))
133 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
134 GetObjectEndpointParamsInterceptor,
135 ))
136 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
137 crate::s3_expires_interceptor::S3ExpiresInterceptor,
138 ))
139 .with_interceptor(::aws_smithy_runtime_api::client::interceptors::SharedInterceptor::permanent(
140 crate::http_response_checksum::ResponseChecksumInterceptor::new(
141 [
142 "crc64nvme",
143 "crc32",
144 "crc32c",
145 "sha256",
146 "sha1",
147 "sha512",
148 "md5",
149 "xxhash64",
150 "xxhash3",
151 "xxhash128",
152 ]
153 .as_slice(),
154 |input: &::aws_smithy_runtime_api::client::interceptors::context::Input| {
155 let input: &crate::operation::get_object::GetObjectInput = input.downcast_ref().expect("correct type");
156 matches!(input.checksum_mode(), ::std::option::Option::Some(crate::types::ChecksumMode::Enabled))
157 },
158 |input: &mut ::aws_smithy_runtime_api::client::interceptors::context::Input, cfg: &::aws_smithy_types::config_bag::ConfigBag| {
159 let input = input
160 .downcast_mut::<crate::operation::get_object::GetObjectInput>()
161 .ok_or("failed to downcast to crate::operation::get_object::GetObjectInput")?;
162
163 let request_validation_enabled = matches!(input.checksum_mode(), Some(crate::types::ChecksumMode::Enabled));
164
165 if !request_validation_enabled {
166 let response_checksum_validation = cfg
168 .load::<::aws_smithy_types::checksum_config::ResponseChecksumValidation>()
169 .unwrap_or(&::aws_smithy_types::checksum_config::ResponseChecksumValidation::WhenSupported);
170
171 let is_presigned_req = cfg.load::<crate::presigning::PresigningMarker>().is_some();
172
173 if is_presigned_req {
175 return ::std::result::Result::Ok(());
176 }
177
178 #[allow(clippy::wildcard_in_or_patterns)]
182 match response_checksum_validation {
183 ::aws_smithy_types::checksum_config::ResponseChecksumValidation::WhenRequired => {}
184 ::aws_smithy_types::checksum_config::ResponseChecksumValidation::WhenSupported | _ => {
185 input.checksum_mode = Some(crate::types::ChecksumMode::Enabled);
186 }
187 }
188 }
189
190 ::std::result::Result::Ok(())
191 },
192 ),
193 ))
194 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::TransientErrorClassifier::<
195 crate::operation::get_object::GetObjectError,
196 >::new())
197 .with_retry_classifier(::aws_smithy_runtime::client::retries::classifiers::ModeledAsRetryableClassifier::<
198 crate::operation::get_object::GetObjectError,
199 >::new())
200 .with_retry_classifier(
201 ::aws_runtime::retries::classifiers::AwsErrorCodeClassifier::<crate::operation::get_object::GetObjectError>::builder()
202 .transient_errors({
203 let mut transient_errors: Vec<&'static str> = ::aws_runtime::retries::classifiers::TRANSIENT_ERRORS.into();
204 transient_errors.push("InternalError");
205 ::std::borrow::Cow::Owned(transient_errors)
206 })
207 .build(),
208 )
209 .with_retry_classifier(::aws_runtime::service_clock_skew::ServiceClockSkewClassifier::<
210 crate::operation::get_object::GetObjectError,
211 >::new());
212
213 ::std::borrow::Cow::Owned(rcb)
214 }
215}
216
217#[derive(Debug)]
218struct GetObjectTelemetryInputCaptureInterceptor;
219
220#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
221impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetObjectTelemetryInputCaptureInterceptor {
222 fn name(&self) -> &'static str {
223 "GetObjectTelemetryInputCaptureInterceptor"
224 }
225
226 fn read_before_execution(
227 &self,
228 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
229 '_,
230 ::aws_smithy_runtime_api::client::interceptors::context::Input,
231 ::aws_smithy_runtime_api::client::interceptors::context::Output,
232 ::aws_smithy_runtime_api::client::interceptors::context::Error,
233 >,
234 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
235 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
236 let ::std::option::Option::Some(requested) = cfg
238 .load::<::aws_smithy_types::telemetry::RequestedTelemetryAttributes>()
239 .filter(|r| !r.is_empty())
240 else {
241 return ::std::result::Result::Ok(());
242 };
243
244 let ::std::option::Option::Some(input) = context.input().downcast_ref::<GetObjectInput>() else {
245 return ::std::result::Result::Ok(());
247 };
248
249 let mut captured = ::aws_smithy_types::telemetry::CapturedTelemetryAttributes::default();
250 if requested.should_capture("Bucket") {
251 if let ::std::option::Option::Some(value) = input.bucket.as_deref() {
252 captured.insert("Bucket", value);
253 }
254 }
255 if requested.should_capture("IfMatch") {
256 if let ::std::option::Option::Some(value) = input.if_match.as_deref() {
257 captured.insert("IfMatch", value);
258 }
259 }
260 if requested.should_capture("IfNoneMatch") {
261 if let ::std::option::Option::Some(value) = input.if_none_match.as_deref() {
262 captured.insert("IfNoneMatch", value);
263 }
264 }
265 if requested.should_capture("Key") {
266 if let ::std::option::Option::Some(value) = input.key.as_deref() {
267 captured.insert("Key", value);
268 }
269 }
270 if requested.should_capture("Range") {
271 if let ::std::option::Option::Some(value) = input.range.as_deref() {
272 captured.insert("Range", value);
273 }
274 }
275 if requested.should_capture("ResponseCacheControl") {
276 if let ::std::option::Option::Some(value) = input.response_cache_control.as_deref() {
277 captured.insert("ResponseCacheControl", value);
278 }
279 }
280 if requested.should_capture("ResponseContentDisposition") {
281 if let ::std::option::Option::Some(value) = input.response_content_disposition.as_deref() {
282 captured.insert("ResponseContentDisposition", value);
283 }
284 }
285 if requested.should_capture("ResponseContentEncoding") {
286 if let ::std::option::Option::Some(value) = input.response_content_encoding.as_deref() {
287 captured.insert("ResponseContentEncoding", value);
288 }
289 }
290 if requested.should_capture("ResponseContentLanguage") {
291 if let ::std::option::Option::Some(value) = input.response_content_language.as_deref() {
292 captured.insert("ResponseContentLanguage", value);
293 }
294 }
295 if requested.should_capture("ResponseContentType") {
296 if let ::std::option::Option::Some(value) = input.response_content_type.as_deref() {
297 captured.insert("ResponseContentType", value);
298 }
299 }
300 if requested.should_capture("VersionId") {
301 if let ::std::option::Option::Some(value) = input.version_id.as_deref() {
302 captured.insert("VersionId", value);
303 }
304 }
305 if requested.should_capture("SSECustomerAlgorithm") {
306 if let ::std::option::Option::Some(value) = input.sse_customer_algorithm.as_deref() {
307 captured.insert("SSECustomerAlgorithm", value);
308 }
309 }
310 if requested.should_capture("SSECustomerKeyMD5") {
311 if let ::std::option::Option::Some(value) = input.sse_customer_key_md5.as_deref() {
312 captured.insert("SSECustomerKeyMD5", value);
313 }
314 }
315 if requested.should_capture("ExpectedBucketOwner") {
316 if let ::std::option::Option::Some(value) = input.expected_bucket_owner.as_deref() {
317 captured.insert("ExpectedBucketOwner", value);
318 }
319 }
320
321 cfg.interceptor_state().store_put(captured);
322 ::std::result::Result::Ok(())
323 }
324}
325#[derive(Debug)]
326struct GetObjectResponseDeserializer;
327impl ::aws_smithy_runtime_api::client::ser_de::DeserializeResponse for GetObjectResponseDeserializer {
328 fn deserialize_streaming(
329 &self,
330 response: &mut ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
331 ) -> ::std::option::Option<::aws_smithy_runtime_api::client::interceptors::context::OutputOrError> {
332 #[allow(unused_mut)]
333 let mut force_error = false;
334 ::tracing::debug!(extended_request_id = ?crate::s3_request_id::RequestIdExt::extended_request_id(response));
335 ::tracing::debug!(request_id = ?::aws_types::request_id::RequestId::request_id(response));
336
337 if (!response.status().is_success() && response.status().as_u16() != 200) || force_error {
339 return ::std::option::Option::None;
340 }
341 ::std::option::Option::Some(crate::protocol_serde::type_erase_result(
342 crate::protocol_serde::shape_get_object::de_get_object_http_response(response),
343 ))
344 }
345
346 fn deserialize_nonstreaming_with_config(
347 &self,
348 response: &::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
349 _cfg: &::aws_smithy_types::config_bag::ConfigBag,
350 ) -> ::aws_smithy_runtime_api::client::interceptors::context::OutputOrError {
351 let body = response.body().bytes().expect("body loaded");
353 crate::protocol_serde::type_erase_result(crate::protocol_serde::shape_get_object::de_get_object_http_error(
354 response.status().as_u16(),
355 response.headers(),
356 body,
357 ))
358 }
359}
360#[derive(Debug)]
361struct GetObjectRequestSerializer;
362impl ::aws_smithy_runtime_api::client::ser_de::SerializeRequest for GetObjectRequestSerializer {
363 #[allow(unused_mut, clippy::let_and_return, clippy::needless_borrow, clippy::useless_conversion)]
364 fn serialize_input(
365 &self,
366 input: ::aws_smithy_runtime_api::client::interceptors::context::Input,
367 _cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
368 ) -> ::std::result::Result<::aws_smithy_runtime_api::client::orchestrator::HttpRequest, ::aws_smithy_runtime_api::box_error::BoxError> {
369 let input = input.downcast::<crate::operation::get_object::GetObjectInput>().expect("correct type");
370 let _header_serialization_settings = _cfg
371 .load::<crate::serialization_settings::HeaderSerializationSettings>()
372 .cloned()
373 .unwrap_or_default();
374 let mut request_builder = {
375 #[allow(clippy::uninlined_format_args)]
376 fn uri_base(
377 _input: &crate::operation::get_object::GetObjectInput,
378 output: &mut ::std::string::String,
379 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
380 use ::std::fmt::Write as _;
381 let input_1 = &_input.key;
382 let input_1 = input_1
383 .as_ref()
384 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "cannot be empty or unset"))?;
385 let key = ::aws_smithy_http::label::fmt_string(input_1, ::aws_smithy_http::label::EncodingStrategy::Greedy);
386 if key.is_empty() {
387 return ::std::result::Result::Err(::aws_smithy_types::error::operation::BuildError::missing_field(
388 "key",
389 "cannot be empty or unset",
390 ));
391 }
392 ::std::write!(output, "/{Key}", Key = key).expect("formatting should succeed");
393 ::std::result::Result::Ok(())
394 }
395 fn uri_query(
396 _input: &crate::operation::get_object::GetObjectInput,
397 mut output: &mut ::std::string::String,
398 ) -> ::std::result::Result<(), ::aws_smithy_types::error::operation::BuildError> {
399 let mut query = ::aws_smithy_http::query::Writer::new(output);
400 query.push_kv("x-id", "GetObject");
401 if let ::std::option::Option::Some(inner_2) = &_input.response_cache_control {
402 {
403 query.push_kv("response-cache-control", &::aws_smithy_http::query::fmt_string(inner_2));
404 }
405 }
406 if let ::std::option::Option::Some(inner_3) = &_input.response_content_disposition {
407 {
408 query.push_kv("response-content-disposition", &::aws_smithy_http::query::fmt_string(inner_3));
409 }
410 }
411 if let ::std::option::Option::Some(inner_4) = &_input.response_content_encoding {
412 {
413 query.push_kv("response-content-encoding", &::aws_smithy_http::query::fmt_string(inner_4));
414 }
415 }
416 if let ::std::option::Option::Some(inner_5) = &_input.response_content_language {
417 {
418 query.push_kv("response-content-language", &::aws_smithy_http::query::fmt_string(inner_5));
419 }
420 }
421 if let ::std::option::Option::Some(inner_6) = &_input.response_content_type {
422 {
423 query.push_kv("response-content-type", &::aws_smithy_http::query::fmt_string(inner_6));
424 }
425 }
426 if let ::std::option::Option::Some(inner_7) = &_input.response_expires {
427 {
428 query.push_kv(
429 "response-expires",
430 &::aws_smithy_http::query::fmt_timestamp(inner_7, ::aws_smithy_types::date_time::Format::HttpDate)?,
431 );
432 }
433 }
434 if let ::std::option::Option::Some(inner_8) = &_input.version_id {
435 {
436 query.push_kv("versionId", &::aws_smithy_http::query::fmt_string(inner_8));
437 }
438 }
439 if let ::std::option::Option::Some(inner_9) = &_input.part_number {
440 {
441 query.push_kv("partNumber", ::aws_smithy_types::primitive::Encoder::from(*inner_9).encode());
442 }
443 }
444 ::std::result::Result::Ok(())
445 }
446 #[allow(clippy::unnecessary_wraps)]
447 fn update_http_builder(
448 input: &crate::operation::get_object::GetObjectInput,
449 builder: ::http_1x::request::Builder,
450 ) -> ::std::result::Result<::http_1x::request::Builder, ::aws_smithy_types::error::operation::BuildError> {
451 let mut uri = ::std::string::String::new();
452 uri_base(input, &mut uri)?;
453 uri_query(input, &mut uri)?;
454 let builder = crate::protocol_serde::shape_get_object::ser_get_object_headers(input, builder)?;
455 ::std::result::Result::Ok(builder.method("GET").uri(uri))
456 }
457 let mut builder = update_http_builder(&input, ::http_1x::request::Builder::new())?;
458 builder
459 };
460 let body = ::aws_smithy_types::body::SdkBody::from("");
461
462 ::std::result::Result::Ok(request_builder.body(body).expect("valid request").try_into().unwrap())
463 }
464}
465#[derive(Debug)]
466struct GetObjectEndpointParamsInterceptor;
467
468#[::aws_smithy_runtime_api::client::interceptors::dyn_dispatch_hint]
469impl ::aws_smithy_runtime_api::client::interceptors::Intercept for GetObjectEndpointParamsInterceptor {
470 fn name(&self) -> &'static str {
471 "GetObjectEndpointParamsInterceptor"
472 }
473
474 fn read_before_execution(
475 &self,
476 context: &::aws_smithy_runtime_api::client::interceptors::context::BeforeSerializationInterceptorContextRef<
477 '_,
478 ::aws_smithy_runtime_api::client::interceptors::context::Input,
479 ::aws_smithy_runtime_api::client::interceptors::context::Output,
480 ::aws_smithy_runtime_api::client::interceptors::context::Error,
481 >,
482 cfg: &mut ::aws_smithy_types::config_bag::ConfigBag,
483 ) -> ::std::result::Result<(), ::aws_smithy_runtime_api::box_error::BoxError> {
484 let _input = context
485 .input()
486 .downcast_ref::<GetObjectInput>()
487 .ok_or("failed to downcast to GetObjectInput")?;
488
489 let params = crate::config::endpoint::Params::builder()
490 .set_region(cfg.load::<::aws_types::region::Region>().map(|r| r.as_ref().to_owned()))
491 .set_use_fips(cfg.load::<::aws_types::endpoint_config::UseFips>().map(|ty| ty.0))
492 .set_use_dual_stack(cfg.load::<::aws_types::endpoint_config::UseDualStack>().map(|ty| ty.0))
493 .set_endpoint(cfg.load::<::aws_types::endpoint_config::EndpointUrl>().map(|ty| ty.0.clone()))
494 .set_force_path_style(cfg.load::<crate::config::ForcePathStyle>().map(|ty| ty.0))
495 .set_use_arn_region(cfg.load::<crate::config::UseArnRegion>().map(|ty| ty.0))
496 .set_disable_multi_region_access_points(cfg.load::<crate::config::DisableMultiRegionAccessPoints>().map(|ty| ty.0))
497 .set_accelerate(cfg.load::<crate::config::Accelerate>().map(|ty| ty.0))
498 .set_disable_s3_express_session_auth(cfg.load::<crate::config::DisableS3ExpressSessionAuth>().map(|ty| ty.0))
499 .set_bucket(Some(
500 _input
501 .bucket
502 .clone()
503 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
504 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("bucket", "A required field was not set"))?,
505 ))
506 .set_key(Some(
507 _input
508 .key
509 .clone()
510 .filter(|f| !AsRef::<str>::as_ref(f).trim().is_empty())
511 .ok_or_else(|| ::aws_smithy_types::error::operation::BuildError::missing_field("key", "A required field was not set"))?,
512 ))
513 .build()
514 .map_err(|err| {
515 ::aws_smithy_runtime_api::client::interceptors::error::ContextAttachedError::new("endpoint params could not be built", err)
516 })?;
517 cfg.interceptor_state()
518 .store_put(::aws_smithy_runtime_api::client::endpoint::EndpointResolverParams::new(params));
519 ::std::result::Result::Ok(())
520 }
521}
522
523#[allow(unreachable_code, unused_variables)]
527#[cfg(test)]
528mod get_object_test {
529
530 #[::tokio::test]
533 #[::tracing_test::traced_test]
534 async fn get_object_if_modified_since_request() {
535 let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
536 let config_builder = crate::config::Config::builder()
537 .with_test_defaults()
538 .allow_no_auth()
541 .endpoint_url("https://example.com");
542 let config_builder = config_builder.region(::aws_types::region::Region::new("us-east-1"));
543 let mut config_builder = config_builder;
544 config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
545
546 let config = config_builder.http_client(http_client).build();
547 let client = crate::Client::from_conf(config);
548 let result = client
549 .get_object()
550 .set_bucket(::std::option::Option::Some("test-bucket".to_owned()))
551 .set_key(::std::option::Option::Some("object.txt".to_owned()))
552 .set_if_modified_since(::std::option::Option::Some(::aws_smithy_types::DateTime::from_fractional_secs(
553 1626452453, 0.123_f64,
554 )))
555 .send()
556 .await;
557 let _ = dbg!(result);
558 let http_request = request_receiver.expect_request();
559 let expected_headers = [("if-modified-since", "Fri, 16 Jul 2021 16:20:53 GMT")];
560 ::aws_smithy_protocol_test::assert_ok(::aws_smithy_protocol_test::validate_headers(http_request.headers(), expected_headers));
561 let uri: ::http_1x::Uri = http_request.uri().parse().expect("invalid URI sent");
562 ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
563 ::pretty_assertions::assert_eq!(uri.path(), "/object.txt", "path was incorrect");
564 }
565
566 #[::tokio::test]
570 #[::tracing_test::traced_test]
571 async fn s3_preserves_leading_dot_segment_in_uri_label_request() {
572 let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
573 let config_builder = crate::config::Config::builder()
574 .with_test_defaults()
575 .allow_no_auth()
578 .endpoint_url("https://s3.us-west-2.amazonaws.com");
579
580 let mut config_builder = config_builder;
581 config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
582
583 let config = config_builder.http_client(http_client).build();
584 let client = crate::Client::from_conf(config);
585 let result = client
586 .get_object()
587 .set_bucket(::std::option::Option::Some("mybucket".to_owned()))
588 .set_key(::std::option::Option::Some("../key.txt".to_owned()))
589 .send()
590 .await;
591 let _ = dbg!(result);
592 let http_request = request_receiver.expect_request();
593 let body = http_request.body().bytes().expect("body should be strict");
594 ::pretty_assertions::assert_eq!(&body, &::bytes::Bytes::new());
596 let uri: ::http_1x::Uri = http_request.uri().parse().expect("invalid URI sent");
597 ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
598 ::pretty_assertions::assert_eq!(uri.path(), "/../key.txt", "path was incorrect");
599 ::pretty_assertions::assert_eq!(uri.host().expect("host should be set"), "mybucket.s3.us-west-2.amazonaws.com");
600 }
601
602 #[::tokio::test]
606 #[::tracing_test::traced_test]
607 async fn s3_preserves_embedded_dot_segment_in_uri_label_request() {
608 let (http_client, request_receiver) = ::aws_smithy_http_client::test_util::capture_request(None);
609 let config_builder = crate::config::Config::builder()
610 .with_test_defaults()
611 .allow_no_auth()
614 .endpoint_url("https://s3.us-west-2.amazonaws.com");
615
616 let mut config_builder = config_builder;
617 config_builder.set_region(Some(crate::config::Region::new("us-east-1")));
618
619 let config = config_builder.http_client(http_client).build();
620 let client = crate::Client::from_conf(config);
621 let result = client
622 .get_object()
623 .set_bucket(::std::option::Option::Some("mybucket".to_owned()))
624 .set_key(::std::option::Option::Some("foo/../key.txt".to_owned()))
625 .send()
626 .await;
627 let _ = dbg!(result);
628 let http_request = request_receiver.expect_request();
629 let body = http_request.body().bytes().expect("body should be strict");
630 ::pretty_assertions::assert_eq!(&body, &::bytes::Bytes::new());
632 let uri: ::http_1x::Uri = http_request.uri().parse().expect("invalid URI sent");
633 ::pretty_assertions::assert_eq!(http_request.method(), "GET", "method was incorrect");
634 ::pretty_assertions::assert_eq!(uri.path(), "/foo/../key.txt", "path was incorrect");
635 ::pretty_assertions::assert_eq!(uri.host().expect("host should be set"), "mybucket.s3.us-west-2.amazonaws.com");
636 }
637}
638
639#[non_exhaustive]
641#[derive(::std::fmt::Debug)]
642pub enum GetObjectError {
643 InvalidObjectState(crate::types::error::InvalidObjectState),
646 NoSuchKey(crate::types::error::NoSuchKey),
648 #[deprecated(note = "Matching `Unhandled` directly is not forwards compatible. Instead, match using a \
650 variable wildcard pattern and check `.code()`:
651 \
652 `err if err.code() == Some(\"SpecificExceptionCode\") => { /* handle the error */ }`
653 \
654 See [`ProvideErrorMetadata`](#impl-ProvideErrorMetadata-for-GetObjectError) for what information is available for the error.")]
655 Unhandled(crate::error::sealed_unhandled::Unhandled),
656}
657impl GetObjectError {
658 pub fn unhandled(
660 err: impl ::std::convert::Into<::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>>,
661 ) -> Self {
662 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
663 source: err.into(),
664 meta: ::std::default::Default::default(),
665 })
666 }
667
668 pub fn generic(err: ::aws_smithy_types::error::ErrorMetadata) -> Self {
670 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
671 source: err.clone().into(),
672 meta: err,
673 })
674 }
675 pub fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
680 match self {
681 Self::InvalidObjectState(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
682 Self::NoSuchKey(e) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(e),
683 Self::Unhandled(e) => &e.meta,
684 }
685 }
686 pub fn is_invalid_object_state(&self) -> bool {
688 matches!(self, Self::InvalidObjectState(_))
689 }
690 pub fn is_no_such_key(&self) -> bool {
692 matches!(self, Self::NoSuchKey(_))
693 }
694}
695impl ::std::error::Error for GetObjectError {
696 fn source(&self) -> ::std::option::Option<&(dyn ::std::error::Error + 'static)> {
697 match self {
698 Self::InvalidObjectState(_inner) => ::std::option::Option::Some(_inner),
699 Self::NoSuchKey(_inner) => ::std::option::Option::Some(_inner),
700 Self::Unhandled(_inner) => ::std::option::Option::Some(&*_inner.source),
701 }
702 }
703}
704impl ::std::fmt::Display for GetObjectError {
705 fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
706 match self {
707 Self::InvalidObjectState(_inner) => _inner.fmt(f),
708 Self::NoSuchKey(_inner) => _inner.fmt(f),
709 Self::Unhandled(_inner) => {
710 if let ::std::option::Option::Some(code) = ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self) {
711 write!(f, "unhandled error ({code})")
712 } else {
713 f.write_str("unhandled error")
714 }
715 }
716 }
717 }
718}
719impl ::aws_smithy_types::retry::ProvideErrorKind for GetObjectError {
720 fn code(&self) -> ::std::option::Option<&str> {
721 ::aws_smithy_types::error::metadata::ProvideErrorMetadata::code(self)
722 }
723 fn retryable_error_kind(&self) -> ::std::option::Option<::aws_smithy_types::retry::ErrorKind> {
724 ::std::option::Option::None
725 }
726}
727impl ::aws_smithy_types::error::metadata::ProvideErrorMetadata for GetObjectError {
728 fn meta(&self) -> &::aws_smithy_types::error::ErrorMetadata {
729 match self {
730 Self::InvalidObjectState(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
731 Self::NoSuchKey(_inner) => ::aws_smithy_types::error::metadata::ProvideErrorMetadata::meta(_inner),
732 Self::Unhandled(_inner) => &_inner.meta,
733 }
734 }
735}
736impl ::aws_smithy_runtime_api::client::result::CreateUnhandledError for GetObjectError {
737 fn create_unhandled_error(
738 source: ::std::boxed::Box<dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync + 'static>,
739 meta: ::std::option::Option<::aws_smithy_types::error::ErrorMetadata>,
740 ) -> Self {
741 Self::Unhandled(crate::error::sealed_unhandled::Unhandled {
742 source,
743 meta: meta.unwrap_or_default(),
744 })
745 }
746}
747impl crate::s3_request_id::RequestIdExt for crate::operation::get_object::GetObjectError {
748 fn extended_request_id(&self) -> Option<&str> {
749 self.meta().extended_request_id()
750 }
751}
752impl ::aws_types::request_id::RequestId for crate::operation::get_object::GetObjectError {
753 fn request_id(&self) -> Option<&str> {
754 self.meta().request_id()
755 }
756}
757
758pub use crate::operation::get_object::_get_object_input::GetObjectInput;
759
760pub use crate::operation::get_object::_get_object_output::GetObjectOutput;
761
762mod _get_object_input;
763
764mod _get_object_output;
765
766pub mod builders;