aws_smithy_runtime/client/
http.rs

1/*
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5use aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
6#[cfg(feature = "default-https-client")]
7use aws_smithy_runtime_api::client::http::SharedHttpClient;
8
9/// Interceptor for connection poisoning.
10pub mod connection_poisoning;
11
12#[deprecated = "Direct HTTP test utility support from `aws-smithy-runtime` crate is deprecated. Please use the `test-util` feature from `aws-smithy-http-client` instead"]
13#[cfg(feature = "test-util")]
14pub mod test_util {
15    #![allow(missing_docs)]
16
17    pub use aws_smithy_http_client::test_util::{
18        legacy_capture_request as capture_request, CaptureRequestHandler, CaptureRequestReceiver,
19    };
20
21    #[cfg(feature = "connector-hyper-0-14-x")]
22    pub mod dvr {
23        pub use aws_smithy_http_client::test_util::dvr::*;
24    }
25
26    pub use aws_smithy_http_client::test_util::{ReplayEvent, StaticReplayClient};
27
28    pub use aws_smithy_http_client::test_util::legacy_infallible::infallible_client_fn;
29
30    pub use aws_smithy_http_client::test_util::NeverClient;
31
32    #[cfg(feature = "connector-hyper-0-14-x")]
33    pub use aws_smithy_http_client::test_util::NeverTcpConnector;
34
35    #[cfg(all(feature = "connector-hyper-0-14-x", feature = "wire-mock"))]
36    #[macro_use]
37    pub mod wire {
38        pub use aws_smithy_http_client::test_util::wire::ev;
39        pub use aws_smithy_http_client::test_util::wire::match_events;
40        pub use aws_smithy_http_client::test_util::wire::matcher;
41        pub use aws_smithy_http_client::test_util::wire::*;
42    }
43}
44
45/// Default HTTP and TLS connectors that use hyper 0.14.x and rustls.
46///
47/// This module is named after the hyper version number since we anticipate
48/// needing to provide equivalent functionality for hyper 1.x in the future.
49#[cfg(feature = "connector-hyper-0-14-x")]
50#[deprecated = "hyper 0.14.x connector is deprecated, please use the `aws-smithy-http-client` crate directly instead."]
51pub mod hyper_014 {
52    #[allow(deprecated)]
53    pub use aws_smithy_http_client::hyper_014::*;
54}
55
56/// HTTP body and body-wrapper types
57pub mod body;
58
59// NOTE: We created default client options to evolve defaults over time (e.g. allow passing a different DNS resolver)
60/// Configuration options for the default HTTPS client
61#[derive(Debug, Clone)]
62pub(crate) struct DefaultClientOptions {
63    _behavior_version: BehaviorVersion,
64}
65
66impl Default for DefaultClientOptions {
67    fn default() -> Self {
68        DefaultClientOptions {
69            _behavior_version: BehaviorVersion::latest(),
70        }
71    }
72}
73
74impl DefaultClientOptions {
75    /// Set the behavior version to use
76    #[allow(unused)]
77    pub(crate) fn with_behavior_version(mut self, behavior_version: BehaviorVersion) -> Self {
78        self._behavior_version = behavior_version;
79        self
80    }
81}
82
83/// Creates an HTTPS client using the default TLS provider
84#[cfg(feature = "default-https-client")]
85pub(crate) fn default_https_client(_options: DefaultClientOptions) -> Option<SharedHttpClient> {
86    use aws_smithy_http_client::{tls, Builder};
87    tracing::trace!("creating a new default hyper 1.x client using rustls<aws-lc>");
88    Some(
89        Builder::new()
90            .tls_provider(tls::Provider::Rustls(
91                tls::rustls_provider::CryptoMode::AwsLc,
92            ))
93            .build_https(),
94    )
95}