Skip to content

Commit d212f8d

Browse files
aws-sdk-rust-ci82marbagrcohdavid-perez
committed
[smithy-rs] Rollup of 8 commits
Includes commits: 7fb78bb6 Add lifetimes in structure impl (#3106) a5f1653c Allow custom writables in Instantiator (#3104) 7768e03e Upgrade semver checks to 0.24.1 (#3102) 5a8b07c6 Small tweaks to the HTTP wrapper (#3099) 06e265df Update SDK external types (#3080) 53dcff3f Build services with a derived configuration object (#3095) 22de9706 Update publisher (#3110) b6841826 Enable the tokio-rt feature for generated crates when bytestream is used (#3113) Co-authored-by: 82marbag <[email protected]> Co-authored-by: Russell Cohen <[email protected]> Co-authored-by: david-perez <[email protected]>
1 parent 0ff4059 commit d212f8d

File tree

24 files changed

+77
-47
lines changed

24 files changed

+77
-47
lines changed

sdk/aws-smithy-runtime-api/src/client/http/request.rs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ impl Headers {
380380
key: impl AsHeaderComponent,
381381
value: impl AsHeaderComponent,
382382
) -> Result<Option<String>, HttpError> {
383-
let key = header_name(key.into_maybe_static()?)?;
383+
let key = header_name(key)?;
384384
let value = header_value(value.into_maybe_static()?)?;
385385
Ok(self
386386
.headers
@@ -404,8 +404,10 @@ impl Headers {
404404
/// Removes all headers with a given key
405405
///
406406
/// If there are multiple entries for this key, the first entry is returned
407-
pub fn remove(&mut self, key: &str) -> Option<HeaderValue> {
408-
self.headers.remove(key)
407+
pub fn remove(&mut self, key: impl AsRef<str>) -> Option<String> {
408+
self.headers
409+
.remove(key.as_ref())
410+
.map(|h| h.as_str().to_string())
409411
}
410412

411413
/// Appends a value to a given key
@@ -427,6 +429,9 @@ mod sealed {
427429
/// If the component can be represented as a Cow<'static, str>, return it
428430
fn into_maybe_static(self) -> Result<MaybeStatic, HttpError>;
429431

432+
/// Return a string reference to this header
433+
fn as_str(&self) -> Result<&str, HttpError>;
434+
430435
/// If a component is already internally represented as a `http02x::HeaderName`, return it
431436
fn repr_as_http02x_header_name(self) -> Result<http0::HeaderName, Self>
432437
where
@@ -440,18 +445,30 @@ mod sealed {
440445
fn into_maybe_static(self) -> Result<MaybeStatic, HttpError> {
441446
Ok(Cow::Borrowed(self))
442447
}
448+
449+
fn as_str(&self) -> Result<&str, HttpError> {
450+
Ok(self)
451+
}
443452
}
444453

445454
impl AsHeaderComponent for String {
446455
fn into_maybe_static(self) -> Result<MaybeStatic, HttpError> {
447456
Ok(Cow::Owned(self))
448457
}
458+
459+
fn as_str(&self) -> Result<&str, HttpError> {
460+
Ok(self)
461+
}
449462
}
450463

451464
impl AsHeaderComponent for Cow<'static, str> {
452465
fn into_maybe_static(self) -> Result<MaybeStatic, HttpError> {
453466
Ok(self)
454467
}
468+
469+
fn as_str(&self) -> Result<&str, HttpError> {
470+
Ok(self.as_ref())
471+
}
455472
}
456473

457474
impl AsHeaderComponent for http0::HeaderValue {
@@ -462,13 +479,21 @@ mod sealed {
462479
.to_string(),
463480
))
464481
}
482+
483+
fn as_str(&self) -> Result<&str, HttpError> {
484+
std::str::from_utf8(self.as_bytes()).map_err(HttpError::header_was_not_a_string)
485+
}
465486
}
466487

467488
impl AsHeaderComponent for http0::HeaderName {
468489
fn into_maybe_static(self) -> Result<MaybeStatic, HttpError> {
469490
Ok(self.to_string().into())
470491
}
471492

493+
fn as_str(&self) -> Result<&str, HttpError> {
494+
Ok(self.as_ref())
495+
}
496+
472497
fn repr_as_http02x_header_name(self) -> Result<http0::HeaderName, Self>
473498
where
474499
Self: Sized,

sdk/aws-smithy-runtime/src/client/orchestrator/endpoints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fn apply_endpoint(
132132
for (header_name, header_values) in endpoint.headers() {
133133
request.headers_mut().remove(header_name);
134134
for value in header_values {
135-
request.headers_mut().insert(
135+
request.headers_mut().append(
136136
HeaderName::from_str(header_name).map_err(|err| {
137137
ResolveEndpointError::message("invalid header name")
138138
.with_source(Some(err.into()))

sdk/backupstorage/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ features = ["macros", "test-util", "rt-multi-thread"]
8585

8686
[features]
8787
rustls = ["aws-smithy-runtime/tls-rustls"]
88-
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
8988
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
89+
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
9090
default = ["rustls", "rt-tokio"]

sdk/cloudsearchdomain/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ features = ["macros", "test-util", "rt-multi-thread"]
8181

8282
[features]
8383
rustls = ["aws-smithy-runtime/tls-rustls"]
84-
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
8584
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
85+
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
8686
default = ["rustls", "rt-tokio"]

sdk/codeartifact/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ features = ["macros", "test-util", "rt-multi-thread"]
8181

8282
[features]
8383
rustls = ["aws-smithy-runtime/tls-rustls"]
84-
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
8584
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
85+
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
8686
default = ["rustls", "rt-tokio"]

sdk/ebs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@ features = ["macros", "test-util", "rt-multi-thread"]
9191

9292
[features]
9393
rustls = ["aws-smithy-runtime/tls-rustls"]
94-
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
9594
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
95+
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
9696
default = ["rustls", "rt-tokio"]

sdk/glacier/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,6 @@ features = ["env-filter", "json"]
134134

135135
[features]
136136
rustls = ["aws-smithy-runtime/tls-rustls"]
137-
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
138137
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
138+
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
139139
default = ["rustls", "rt-tokio"]

sdk/kinesisvideoarchivedmedia/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ features = ["macros", "test-util", "rt-multi-thread"]
8181

8282
[features]
8383
rustls = ["aws-smithy-runtime/tls-rustls"]
84-
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
8584
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
85+
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
8686
default = ["rustls", "rt-tokio"]

sdk/kinesisvideomedia/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ features = ["macros", "test-util", "rt-multi-thread"]
8181

8282
[features]
8383
rustls = ["aws-smithy-runtime/tls-rustls"]
84-
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
8584
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
85+
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
8686
default = ["rustls", "rt-tokio"]

sdk/lakeformation/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ features = ["macros", "test-util", "rt-multi-thread"]
8181

8282
[features]
8383
rustls = ["aws-smithy-runtime/tls-rustls"]
84-
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
8584
test-util = ["aws-credential-types/test-util", "aws-smithy-runtime/test-util"]
85+
rt-tokio = ["aws-smithy-async/rt-tokio", "aws-smithy-types/rt-tokio"]
8686
default = ["rustls", "rt-tokio"]

0 commit comments

Comments
 (0)