Skip to content

Commit

Permalink
Clean up aws-smithy-http
Browse files Browse the repository at this point in the history
  • Loading branch information
jdisanti committed Oct 6, 2023
1 parent b02239a commit 365f787
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 1,296 deletions.
26 changes: 8 additions & 18 deletions aws/rust-runtime/aws-http/src/request_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

use aws_smithy_http::http::HttpHeaders;
use aws_smithy_http::operation;
use aws_smithy_http::result::SdkError;
use aws_smithy_types::error::metadata::{
Builder as ErrorMetadataBuilder, ErrorMetadata, ProvideErrorMetadata,
Expand Down Expand Up @@ -46,12 +45,6 @@ impl RequestId for Unhandled {
}
}

impl RequestId for operation::Response {
fn request_id(&self) -> Option<&str> {
extract_request_id(self.http().headers())
}
}

impl<B> RequestId for http::Response<B> {
fn request_id(&self) -> Option<&str> {
extract_request_id(self.headers())
Expand Down Expand Up @@ -106,18 +99,15 @@ mod tests {

#[test]
fn test_request_id_sdk_error() {
let without_request_id =
|| operation::Response::new(Response::builder().body(SdkBody::empty()).unwrap());
let without_request_id = || Response::builder().body(SdkBody::empty()).unwrap();
let with_request_id = || {
operation::Response::new(
Response::builder()
.header(
"x-amzn-requestid",
HeaderValue::from_static("some-request-id"),
)
.body(SdkBody::empty())
.unwrap(),
)
Response::builder()
.header(
"x-amzn-requestid",
HeaderValue::from_static("some-request-id"),
)
.body(SdkBody::empty())
.unwrap()
};
assert_eq!(
None,
Expand Down
6 changes: 3 additions & 3 deletions aws/rust-runtime/aws-http/src/user_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use std::fmt;

/// AWS User Agent
///
/// Ths struct should be inserted into the [`PropertyBag`](aws_smithy_http::operation::Request::properties)
/// during operation construction. [`UserAgentStage`](UserAgentStage) reads `AwsUserAgent`
/// from the property bag and sets the `User-Agent` and `x-amz-user-agent` headers.
/// Ths struct should be inserted into the [`ConfigBag`](aws_smithy_types::config_bag::ConfigBag)
/// during operation construction. The `UserAgentInterceptor` reads `AwsUserAgent`
/// from the config bag and sets the `User-Agent` and `x-amz-user-agent` headers.
#[derive(Clone, Debug)]
pub struct AwsUserAgent {
sdk_metadata: SdkMetadata,
Expand Down
20 changes: 5 additions & 15 deletions aws/rust-runtime/aws-inlineable/src/s3_request_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

use aws_smithy_http::http::HttpHeaders;
use aws_smithy_http::operation;
use aws_smithy_http::result::SdkError;
use aws_smithy_types::error::metadata::{
Builder as ErrorMetadataBuilder, ErrorMetadata, ProvideErrorMetadata,
Expand Down Expand Up @@ -47,12 +46,6 @@ impl RequestIdExt for Unhandled {
}
}

impl RequestIdExt for operation::Response {
fn extended_request_id(&self) -> Option<&str> {
extract_extended_request_id(self.http().headers())
}
}

impl<B> RequestIdExt for http::Response<B> {
fn extended_request_id(&self) -> Option<&str> {
extract_extended_request_id(self.headers())
Expand Down Expand Up @@ -115,15 +108,12 @@ mod test {

#[test]
fn test_extended_request_id_sdk_error() {
let without_extended_request_id =
|| operation::Response::new(Response::builder().body(SdkBody::empty()).unwrap());
let without_extended_request_id = || Response::builder().body(SdkBody::empty()).unwrap();
let with_extended_request_id = || {
operation::Response::new(
Response::builder()
.header("x-amz-id-2", HeaderValue::from_static("some-request-id"))
.body(SdkBody::empty())
.unwrap(),
)
Response::builder()
.header("x-amz-id-2", HeaderValue::from_static("some-request-id"))
.body(SdkBody::empty())
.unwrap()
};
assert_eq!(
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import software.amazon.smithy.rust.codegen.core.rustlang.Writable
import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate
import software.amazon.smithy.rust.codegen.core.rustlang.writable
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeConfig
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType
import software.amazon.smithy.rust.codegen.core.smithy.RustCrate
import software.amazon.smithy.rust.codegen.core.util.dq
import software.amazon.smithy.rust.codegen.core.util.getTrait
Expand All @@ -51,7 +50,6 @@ private fun codegenScope(runtimeConfig: RuntimeConfig): Array<Pair<String, Any>>
"HTTP_DIGEST_AUTH_SCHEME_ID" to authHttpApi.resolve("HTTP_DIGEST_AUTH_SCHEME_ID"),
"IdentityResolver" to smithyRuntimeApi.resolve("client::identity::IdentityResolver"),
"Login" to smithyRuntimeApi.resolve("client::identity::http::Login"),
"PropertyBag" to RuntimeType.smithyHttp(runtimeConfig).resolve("property_bag::PropertyBag"),
"SharedAuthScheme" to smithyRuntimeApi.resolve("client::auth::SharedAuthScheme"),
"SharedIdentityResolver" to smithyRuntimeApi.resolve("client::identity::SharedIdentityResolver"),
"Token" to smithyRuntimeApi.resolve("client::identity::http::Token"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ data class RuntimeType(val path: String, val dependency: RustDependency? = null)

fun blob(runtimeConfig: RuntimeConfig) = smithyTypes(runtimeConfig).resolve("Blob")
fun byteStream(runtimeConfig: RuntimeConfig) = smithyHttp(runtimeConfig).resolve("byte_stream::ByteStream")
fun classifyRetry(runtimeConfig: RuntimeConfig) = smithyHttp(runtimeConfig).resolve("retry::ClassifyRetry")
fun dateTime(runtimeConfig: RuntimeConfig) = smithyTypes(runtimeConfig).resolve("DateTime")
fun document(runtimeConfig: RuntimeConfig): RuntimeType = smithyTypes(runtimeConfig).resolve("Document")
fun format(runtimeConfig: RuntimeConfig) = smithyTypes(runtimeConfig).resolve("date_time::Format")
Expand All @@ -422,11 +421,6 @@ data class RuntimeType(val path: String, val dependency: RustDependency? = null)
fun labelFormat(runtimeConfig: RuntimeConfig, func: String) = smithyHttp(runtimeConfig).resolve("label::$func")
fun operation(runtimeConfig: RuntimeConfig) = smithyHttp(runtimeConfig).resolve("operation::Operation")
fun operationModule(runtimeConfig: RuntimeConfig) = smithyHttp(runtimeConfig).resolve("operation")
fun parseHttpResponse(runtimeConfig: RuntimeConfig) =
smithyHttp(runtimeConfig).resolve("response::ParseHttpResponse")

fun parseStrictResponse(runtimeConfig: RuntimeConfig) =
smithyHttp(runtimeConfig).resolve("response::ParseStrictResponse")

fun protocolTest(runtimeConfig: RuntimeConfig, func: String): RuntimeType =
smithyProtocolTest(runtimeConfig).resolve(func)
Expand Down
1 change: 0 additions & 1 deletion rust-runtime/aws-smithy-http/src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use std::str::FromStr;
use std::sync::Arc;

pub mod error;
pub mod middleware;

pub use error::ResolveEndpointError;

Expand Down
87 changes: 0 additions & 87 deletions rust-runtime/aws-smithy-http/src/endpoint/middleware.rs

This file was deleted.

10 changes: 0 additions & 10 deletions rust-runtime/aws-smithy-http/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,3 @@ impl<B> HttpHeaders for http::Response<B> {
self.headers_mut()
}
}

impl HttpHeaders for crate::operation::Response {
fn http_headers(&self) -> &HeaderMap<HeaderValue> {
self.http().http_headers()
}

fn http_headers_mut(&mut self) -> &mut HeaderMap<HeaderValue> {
self.http_mut().http_headers_mut()
}
}
4 changes: 0 additions & 4 deletions rust-runtime/aws-smithy-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,11 @@ pub mod futures_stream_adapter;
pub mod header;
pub mod http;
pub mod label;
pub mod middleware;
pub mod operation;
pub mod property_bag;
pub mod query;
#[doc(hidden)]
pub mod query_writer;
pub mod response;
pub mod result;
pub mod retry;

#[cfg(feature = "event-stream")]
pub mod event_stream;
Expand Down
Loading

0 comments on commit 365f787

Please sign in to comment.