1use crate::client::http::body::content_length_enforcement::EnforceContentLengthRuntimePlugin;
13use crate::client::identity::IdentityCache;
14use crate::client::retries::strategy::standard::TokenBucketProvider;
15use crate::client::retries::strategy::StandardRetryStrategy;
16use crate::client::retries::RetryPartition;
17use aws_smithy_async::rt::sleep::default_async_sleep;
18use aws_smithy_async::time::SystemTimeSource;
19use aws_smithy_runtime_api::box_error::BoxError;
20use aws_smithy_runtime_api::client::behavior_version::BehaviorVersion;
21use aws_smithy_runtime_api::client::http::SharedHttpClient;
22use aws_smithy_runtime_api::client::interceptors::SharedInterceptor;
23use aws_smithy_runtime_api::client::runtime_components::{
24 RuntimeComponentsBuilder, SharedConfigValidator,
25};
26use aws_smithy_runtime_api::client::runtime_plugin::{
27 Order, SharedRuntimePlugin, StaticRuntimePlugin,
28};
29use aws_smithy_runtime_api::client::stalled_stream_protection::StalledStreamProtectionConfig;
30use aws_smithy_runtime_api::shared::IntoShared;
31use aws_smithy_types::config_bag::{ConfigBag, FrozenLayer, Layer};
32use aws_smithy_types::retry::{ReconnectMode, RetryConfig, RetrySpec};
33use aws_smithy_types::timeout::TimeoutConfig;
34use std::borrow::Cow;
35use std::time::Duration;
36
37pub(crate) const DEFAULT_CONNECT_TIMEOUT: Duration = Duration::from_millis(3100);
39
40fn default_plugin<CompFn>(name: &'static str, components_fn: CompFn) -> StaticRuntimePlugin
41where
42 CompFn: FnOnce(RuntimeComponentsBuilder) -> RuntimeComponentsBuilder,
43{
44 StaticRuntimePlugin::new()
45 .with_order(Order::Defaults)
46 .with_runtime_components((components_fn)(RuntimeComponentsBuilder::new(name)))
47}
48
49fn layer<LayerFn>(name: &'static str, layer_fn: LayerFn) -> FrozenLayer
50where
51 LayerFn: FnOnce(&mut Layer),
52{
53 let mut layer = Layer::new(name);
54 (layer_fn)(&mut layer);
55 layer.freeze()
56}
57
58#[deprecated(
60 since = "1.8.0",
61 note = "This function wasn't intended to be public, and didn't take the behavior major version as an argument, so it couldn't be evolved over time."
62)]
63pub fn default_http_client_plugin() -> Option<SharedRuntimePlugin> {
64 #[expect(deprecated)]
65 default_http_client_plugin_v2(BehaviorVersion::v2024_03_28())
66}
67
68#[cfg(feature = "connector-hyper-0-14-x")]
79fn warn_legacy_client_default_is_changing(behavior_version: BehaviorVersion) {
80 let emit = || {
81 tracing::warn!(
82 behavior_version = ?behavior_version,
83 "this build resolves to the legacy hyper 0.14.x / http 0.2.x HTTP client. In the 2.x \
84 release, currently expected November 2026, the default becomes the hyper 1.x client: \
85 a different TLS implementation, with different connection-pooling and timeout \
86 behavior. To keep the legacy client, add `features = [\"legacy-https-client\"]` to \
87 your AWS SDK crate now — that spelling is stable across the change, whereas `rustls` \
88 will become a synonym for the hyper 1.x client. To move early instead, use \
89 `BehaviorVersion::v2026_01_12()` or later. \
90 See https://github.com/smithy-lang/smithy-rs/issues/4489",
91 );
92 };
93
94 #[cfg(not(test))]
98 {
99 static WARNED: std::sync::Once = std::sync::Once::new();
100 WARNED.call_once(emit);
101 }
102 #[cfg(test)]
103 emit();
104}
105
106pub fn default_http_client_plugin_v2(
108 behavior_version: BehaviorVersion,
109) -> Option<SharedRuntimePlugin> {
110 let mut _default: Option<SharedHttpClient> = None;
111
112 #[allow(deprecated)]
113 if behavior_version.is_at_least(BehaviorVersion::v2026_01_12()) {
114 #[cfg(all(
118 feature = "connector-hyper-0-14-x",
119 not(feature = "default-https-client")
120 ))]
121 #[allow(deprecated)]
122 {
123 _default = crate::client::http::hyper_014::default_client();
124
125 if _default.is_some() {
128 warn_legacy_client_default_is_changing(behavior_version);
129 }
130 }
131
132 #[cfg(feature = "default-https-client")]
134 {
135 let opts = crate::client::http::DefaultClientOptions::default()
136 .with_behavior_version(behavior_version);
137 _default = crate::client::http::default_https_client(opts);
138 }
139 } else {
140 #[cfg(feature = "connector-hyper-0-14-x")]
142 #[allow(deprecated)]
143 {
144 _default = crate::client::http::hyper_014::default_client();
145
146 if _default.is_some() {
149 warn_legacy_client_default_is_changing(behavior_version);
150 }
151 }
152
153 #[cfg(feature = "default-https-client")]
162 if _default.is_none() {
163 let opts = crate::client::http::DefaultClientOptions::default()
164 .with_behavior_version(behavior_version);
165 _default = crate::client::http::default_https_client(opts);
166
167 if _default.is_some() {
171 tracing::warn!(
172 behavior_version = ?behavior_version,
173 "this behavior version selects the legacy hyper 0.14.x HTTP client, which is \
174 not available in this build, so the default hyper 1.x HTTPS client is being \
175 used instead. Enable the `legacy-https-client` feature on your AWS SDK crate \
176 (or `aws-smithy-runtime/tls-rustls`) to get the legacy stack, or move to \
177 `BehaviorVersion::v2026_01_12()` or later to stop seeing this warning.",
178 );
179 }
180 }
181 }
182
183 _default.map(|default| {
184 default_plugin("default_http_client_plugin", |components| {
185 components.with_http_client(Some(default))
186 })
187 .into_shared()
188 })
189}
190
191pub fn default_sleep_impl_plugin() -> Option<SharedRuntimePlugin> {
193 default_async_sleep().map(|default| {
194 default_plugin("default_sleep_impl_plugin", |components| {
195 components.with_sleep_impl(Some(default))
196 })
197 .into_shared()
198 })
199}
200
201pub fn default_time_source_plugin() -> Option<SharedRuntimePlugin> {
203 Some(
204 default_plugin("default_time_source_plugin", |components| {
205 components.with_time_source(Some(SystemTimeSource::new()))
206 })
207 .into_shared(),
208 )
209}
210
211pub fn default_retry_config_plugin(
213 default_partition_name: impl Into<Cow<'static, str>>,
214) -> Option<SharedRuntimePlugin> {
215 let retry_partition = RetryPartition::new(default_partition_name);
216 Some(
217 default_plugin("default_retry_config_plugin", |components| {
218 components
219 .with_retry_strategy(Some(StandardRetryStrategy::new()))
220 .with_config_validator(SharedConfigValidator::base_client_config_fn(
221 validate_retry_config,
222 ))
223 .with_interceptor(SharedInterceptor::permanent(TokenBucketProvider::new(
224 retry_partition.clone(),
225 )))
226 })
227 .with_config(layer("default_retry_config", |layer| {
228 layer.store_put(RetryConfig::disabled());
229 layer.store_put(retry_partition);
230 }))
231 .into_shared(),
232 )
233}
234
235pub fn default_retry_config_plugin_v2(params: &DefaultPluginParams) -> Option<SharedRuntimePlugin> {
241 let retry_partition = RetryPartition::new(
242 params
243 .retry_partition_name
244 .as_ref()
245 .expect("retry partition name is required")
246 .clone(),
247 );
248 let is_aws_sdk = params.is_aws_sdk;
249 let behavior_version = params
250 .behavior_version
251 .unwrap_or_else(BehaviorVersion::latest);
252 Some(
253 default_plugin("default_retry_config_plugin", |components| {
254 components
255 .with_retry_strategy(Some(StandardRetryStrategy::new()))
256 .with_config_validator(SharedConfigValidator::base_client_config_fn(
257 validate_retry_config,
258 ))
259 .with_interceptor(SharedInterceptor::permanent(TokenBucketProvider::new(
260 retry_partition.clone(),
261 )))
262 })
263 .with_config(layer("default_retry_config", |layer| {
264 #[allow(deprecated)]
265 let retry_config =
266 if is_aws_sdk && behavior_version.is_at_least(BehaviorVersion::v2026_01_12()) {
267 RetryConfig::standard()
268 } else {
269 RetryConfig::disabled()
270 };
271 #[allow(deprecated)]
272 let retry_config = if behavior_version.is_at_least(BehaviorVersion::v2026_11_10()) {
273 retry_config
274 .with_retry_spec(RetrySpec::v2_1())
275 .with_reconnect_mode(ReconnectMode::ReuseAllConnections)
276 } else {
277 retry_config
278 };
279 layer.store_put(retry_config);
280 layer.store_put(retry_partition);
281 }))
282 .into_shared(),
283 )
284}
285
286fn validate_retry_config(
287 components: &RuntimeComponentsBuilder,
288 cfg: &ConfigBag,
289) -> Result<(), BoxError> {
290 if let Some(retry_config) = cfg.load::<RetryConfig>() {
291 if retry_config.has_retry() && components.sleep_impl().is_none() {
292 Err("An async sleep implementation is required for retry to work. Please provide a `sleep_impl` on \
293 the config, or disable timeouts.".into())
294 } else {
295 Ok(())
296 }
297 } else {
298 Err(
299 "The default retry config was removed, and no other config was put in its place."
300 .into(),
301 )
302 }
303}
304
305pub fn default_timeout_config_plugin() -> Option<SharedRuntimePlugin> {
307 Some(
308 default_plugin("default_timeout_config_plugin", |components| {
309 components.with_config_validator(SharedConfigValidator::base_client_config_fn(
310 validate_timeout_config,
311 ))
312 })
313 .with_config(layer("default_timeout_config", |layer| {
314 layer.store_put(TimeoutConfig::disabled());
315 }))
316 .into_shared(),
317 )
318}
319
320pub fn default_timeout_config_plugin_v2(
325 params: &DefaultPluginParams,
326) -> Option<SharedRuntimePlugin> {
327 let behavior_version = params
328 .behavior_version
329 .unwrap_or_else(BehaviorVersion::latest);
330 Some(
331 default_plugin("default_timeout_config_plugin", |components| {
332 components.with_config_validator(SharedConfigValidator::base_client_config_fn(
333 validate_timeout_config,
334 ))
335 })
336 .with_config(layer("default_timeout_config", |layer| {
337 #[allow(deprecated)]
338 let timeout_config = if behavior_version.is_at_least(BehaviorVersion::v2026_01_12()) {
339 TimeoutConfig::builder()
341 .connect_timeout(DEFAULT_CONNECT_TIMEOUT)
342 .build()
343 } else {
344 TimeoutConfig::disabled()
346 };
347 layer.store_put(timeout_config);
348 }))
349 .into_shared(),
350 )
351}
352
353fn validate_timeout_config(
354 components: &RuntimeComponentsBuilder,
355 cfg: &ConfigBag,
356) -> Result<(), BoxError> {
357 if let Some(timeout_config) = cfg.load::<TimeoutConfig>() {
358 if timeout_config.has_timeouts() && components.sleep_impl().is_none() {
359 Err("An async sleep implementation is required for timeouts to work. Please provide a `sleep_impl` on \
360 the config, or disable timeouts.".into())
361 } else {
362 Ok(())
363 }
364 } else {
365 Err(
366 "The default timeout config was removed, and no other config was put in its place."
367 .into(),
368 )
369 }
370}
371
372pub fn default_identity_cache_plugin() -> Option<SharedRuntimePlugin> {
374 Some(
375 default_plugin("default_identity_cache_plugin", |components| {
376 components.with_identity_cache(Some(IdentityCache::lazy().build()))
377 })
378 .into_shared(),
379 )
380}
381
382#[deprecated(
387 since = "1.2.0",
388 note = "This function wasn't intended to be public, and didn't take the behavior major version as an argument, so it couldn't be evolved over time."
389)]
390pub fn default_stalled_stream_protection_config_plugin() -> Option<SharedRuntimePlugin> {
391 #[expect(deprecated)]
392 default_stalled_stream_protection_config_plugin_v2(BehaviorVersion::v2023_11_09())
393}
394fn default_stalled_stream_protection_config_plugin_v2(
395 behavior_version: BehaviorVersion,
396) -> Option<SharedRuntimePlugin> {
397 Some(
398 default_plugin(
399 "default_stalled_stream_protection_config_plugin",
400 |components| {
401 components.with_config_validator(SharedConfigValidator::base_client_config_fn(
402 validate_stalled_stream_protection_config,
403 ))
404 },
405 )
406 .with_config(layer("default_stalled_stream_protection_config", |layer| {
407 let mut config =
408 StalledStreamProtectionConfig::enabled().grace_period(Duration::from_secs(5));
409 #[expect(deprecated)]
411 if !behavior_version.is_at_least(BehaviorVersion::v2024_03_28()) {
412 config = config.upload_enabled(false);
413 }
414 layer.store_put(config.build());
415 }))
416 .into_shared(),
417 )
418}
419
420fn enforce_content_length_runtime_plugin() -> Option<SharedRuntimePlugin> {
421 Some(EnforceContentLengthRuntimePlugin::new().into_shared())
422}
423
424fn validate_stalled_stream_protection_config(
425 components: &RuntimeComponentsBuilder,
426 cfg: &ConfigBag,
427) -> Result<(), BoxError> {
428 if let Some(stalled_stream_protection_config) = cfg.load::<StalledStreamProtectionConfig>() {
429 if stalled_stream_protection_config.is_enabled() {
430 if components.sleep_impl().is_none() {
431 return Err(
432 "An async sleep implementation is required for stalled stream protection to work. \
433 Please provide a `sleep_impl` on the config, or disable stalled stream protection.".into());
434 }
435
436 if components.time_source().is_none() {
437 return Err(
438 "A time source is required for stalled stream protection to work.\
439 Please provide a `time_source` on the config, or disable stalled stream protection.".into());
440 }
441 }
442
443 Ok(())
444 } else {
445 Err(
446 "The default stalled stream protection config was removed, and no other config was put in its place."
447 .into(),
448 )
449 }
450}
451
452#[non_exhaustive]
456#[derive(Debug, Default)]
457pub struct DefaultPluginParams {
458 retry_partition_name: Option<Cow<'static, str>>,
459 behavior_version: Option<BehaviorVersion>,
460 is_aws_sdk: bool,
461}
462
463impl DefaultPluginParams {
464 pub fn new() -> Self {
466 Default::default()
467 }
468
469 pub fn with_retry_partition_name(mut self, name: impl Into<Cow<'static, str>>) -> Self {
471 self.retry_partition_name = Some(name.into());
472 self
473 }
474
475 pub fn with_behavior_version(mut self, version: BehaviorVersion) -> Self {
477 self.behavior_version = Some(version);
478 self
479 }
480
481 pub fn with_is_aws_sdk(mut self, is_aws_sdk: bool) -> Self {
483 self.is_aws_sdk = is_aws_sdk;
484 self
485 }
486}
487
488pub fn default_plugins(
490 params: DefaultPluginParams,
491) -> impl IntoIterator<Item = SharedRuntimePlugin> {
492 let behavior_version = params
493 .behavior_version
494 .unwrap_or_else(BehaviorVersion::latest);
495
496 [
497 default_http_client_plugin_v2(behavior_version),
498 default_identity_cache_plugin(),
499 default_retry_config_plugin_v2(¶ms),
500 default_sleep_impl_plugin(),
501 default_time_source_plugin(),
502 default_timeout_config_plugin_v2(¶ms),
503 enforce_content_length_runtime_plugin(),
504 default_stalled_stream_protection_config_plugin_v2(behavior_version),
505 ]
506 .into_iter()
507 .flatten()
508 .collect::<Vec<SharedRuntimePlugin>>()
509}
510
511#[cfg(test)]
512mod tests {
513 use super::*;
514 use aws_smithy_runtime_api::client::runtime_plugin::{RuntimePlugin, RuntimePlugins};
515 #[cfg(any(feature = "default-https-client", feature = "tls-rustls"))]
516 use tracing_test::traced_test;
517
518 fn test_plugin_params(version: BehaviorVersion) -> DefaultPluginParams {
519 DefaultPluginParams::new()
520 .with_behavior_version(version)
521 .with_retry_partition_name("dontcare")
522 .with_is_aws_sdk(false) }
524 fn config_for(plugins: impl IntoIterator<Item = SharedRuntimePlugin>) -> ConfigBag {
525 let mut config = ConfigBag::base();
526 let plugins = RuntimePlugins::new().with_client_plugins(plugins);
527 plugins.apply_client_configuration(&mut config).unwrap();
528 config
529 }
530
531 #[test]
532 #[expect(deprecated)]
533 fn v2024_03_28_stalled_stream_protection_difference() {
534 let latest = config_for(default_plugins(test_plugin_params(
535 BehaviorVersion::latest(),
536 )));
537 let v2023 = config_for(default_plugins(test_plugin_params(
538 BehaviorVersion::v2023_11_09(),
539 )));
540
541 assert!(
542 latest
543 .load::<StalledStreamProtectionConfig>()
544 .unwrap()
545 .upload_enabled(),
546 "stalled stream protection on uploads MUST be enabled after v2024_03_28"
547 );
548 assert!(
549 !v2023
550 .load::<StalledStreamProtectionConfig>()
551 .unwrap()
552 .upload_enabled(),
553 "stalled stream protection on uploads MUST NOT be enabled before v2024_03_28"
554 );
555 }
556
557 #[test]
558 fn test_retry_enabled_for_aws_sdk() {
559 let params = DefaultPluginParams::new()
560 .with_retry_partition_name("test-partition")
561 .with_behavior_version(BehaviorVersion::latest())
562 .with_is_aws_sdk(true);
563 let plugin = default_retry_config_plugin_v2(¶ms).expect("plugin should be created");
564
565 let config = plugin.config().expect("config should exist");
566 let retry_config = config
567 .load::<RetryConfig>()
568 .expect("retry config should exist");
569
570 assert_eq!(
571 retry_config.max_attempts(),
572 3,
573 "retries should be enabled with max_attempts=3 for AWS SDK with latest behavior version"
574 );
575 }
576
577 #[test]
578 #[expect(deprecated)]
579 fn test_retry_disabled_for_aws_sdk_old_behavior_version() {
580 let params = DefaultPluginParams::new()
582 .with_retry_partition_name("test-partition")
583 .with_behavior_version(BehaviorVersion::v2024_03_28())
584 .with_is_aws_sdk(true);
585 let plugin = default_retry_config_plugin_v2(¶ms).expect("plugin should be created");
586
587 let config = plugin.config().expect("config should exist");
588 let retry_config = config
589 .load::<RetryConfig>()
590 .expect("retry config should exist");
591
592 assert_eq!(
593 retry_config.max_attempts(),
594 1,
595 "retries should be disabled for AWS SDK with behavior version < v2026_01_12"
596 );
597 }
598
599 #[test]
600 #[allow(deprecated)]
601 fn test_retry_enabled_at_cutoff_version() {
602 let params = DefaultPluginParams::new()
604 .with_retry_partition_name("test-partition")
605 .with_behavior_version(BehaviorVersion::v2026_01_12())
606 .with_is_aws_sdk(true);
607 let plugin = default_retry_config_plugin_v2(¶ms).expect("plugin should be created");
608
609 let config = plugin.config().expect("config should exist");
610 let retry_config = config
611 .load::<RetryConfig>()
612 .expect("retry config should exist");
613
614 assert_eq!(
615 retry_config.max_attempts(),
616 3,
617 "retries should be enabled for AWS SDK starting from v2026_01_12"
618 );
619 }
620
621 #[test]
622 fn test_retry_disabled_for_non_aws_sdk() {
623 let params = DefaultPluginParams::new()
624 .with_retry_partition_name("test-partition")
625 .with_behavior_version(BehaviorVersion::latest())
626 .with_is_aws_sdk(false);
627 let plugin = default_retry_config_plugin_v2(¶ms).expect("plugin should be created");
628
629 let config = plugin.config().expect("config should exist");
630 let retry_config = config
631 .load::<RetryConfig>()
632 .expect("retry config should exist");
633
634 assert_eq!(
635 retry_config.max_attempts(),
636 1,
637 "retries should be disabled for non-AWS SDK clients"
638 );
639 }
640
641 #[test]
642 #[expect(deprecated)]
643 fn test_behavior_version_gates_retry_for_aws_sdk() {
644 let test_cases = vec![
649 (BehaviorVersion::v2023_11_09(), 1, "v2023_11_09 (old)"),
650 (BehaviorVersion::v2024_03_28(), 1, "v2024_03_28 (old)"),
651 (BehaviorVersion::v2025_01_17(), 1, "v2025_01_17 (old)"),
652 (BehaviorVersion::v2025_08_07(), 1, "v2025_08_07 (old)"),
653 (BehaviorVersion::v2026_01_12(), 3, "v2026_01_12 (cutoff)"),
654 (BehaviorVersion::latest(), 3, "latest"),
655 ];
656
657 for (version, expected_attempts, version_name) in test_cases {
658 let params = DefaultPluginParams::new()
659 .with_retry_partition_name("test-partition")
660 .with_behavior_version(version)
661 .with_is_aws_sdk(true);
662
663 let plugin = default_retry_config_plugin_v2(¶ms).expect("plugin should be created");
664 let config = plugin.config().expect("config should exist");
665 let retry_config = config
666 .load::<RetryConfig>()
667 .expect("retry config should exist");
668
669 assert_eq!(
670 retry_config.max_attempts(),
671 expected_attempts,
672 "AWS SDK with {} should have {} max attempts",
673 version_name,
674 expected_attempts
675 );
676 }
677 }
678
679 #[test]
680 #[expect(deprecated)]
681 fn test_complete_default_plugins_integration() {
682 let params_aws_latest = DefaultPluginParams::new()
688 .with_retry_partition_name("aws-s3")
689 .with_behavior_version(BehaviorVersion::latest())
690 .with_is_aws_sdk(true);
691
692 let config_aws_latest = config_for(default_plugins(params_aws_latest));
693 let retry_aws_latest = config_aws_latest
694 .load::<RetryConfig>()
695 .expect("retry config should exist");
696 assert_eq!(
697 retry_aws_latest.max_attempts(),
698 3,
699 "AWS SDK with latest behavior version should have retries enabled (3 attempts)"
700 );
701
702 let params_aws_old = DefaultPluginParams::new()
704 .with_retry_partition_name("aws-s3")
705 .with_behavior_version(BehaviorVersion::v2024_03_28())
706 .with_is_aws_sdk(true);
707
708 let config_aws_old = config_for(default_plugins(params_aws_old));
709 let retry_aws_old = config_aws_old
710 .load::<RetryConfig>()
711 .expect("retry config should exist");
712 assert_eq!(
713 retry_aws_old.max_attempts(),
714 1,
715 "AWS SDK with old behavior version should have retries disabled (1 attempt)"
716 );
717
718 let params_generic = DefaultPluginParams::new()
720 .with_retry_partition_name("my-service")
721 .with_behavior_version(BehaviorVersion::latest())
722 .with_is_aws_sdk(false);
723
724 let config_generic = config_for(default_plugins(params_generic));
725 let retry_generic = config_generic
726 .load::<RetryConfig>()
727 .expect("retry config should exist");
728 assert_eq!(
729 retry_generic.max_attempts(),
730 1,
731 "Non-AWS SDK clients should always have retries disabled (1 attempt)"
732 );
733
734 let params_cutoff = DefaultPluginParams::new()
736 .with_retry_partition_name("aws-s3")
737 .with_behavior_version(BehaviorVersion::v2026_01_12())
738 .with_is_aws_sdk(true);
739
740 let config_cutoff = config_for(default_plugins(params_cutoff));
741 let retry_cutoff = config_cutoff
742 .load::<RetryConfig>()
743 .expect("retry config should exist");
744 assert_eq!(
745 retry_cutoff.max_attempts(),
746 3,
747 "AWS SDK with v2026_01_12 (the cutoff version) should have retries enabled (3 attempts)"
748 );
749 }
750
751 #[test]
762 #[expect(deprecated)]
763 fn old_behavior_version_still_gets_an_http_client() {
764 let old = default_http_client_plugin_v2(BehaviorVersion::v2024_03_28());
765 let latest = default_http_client_plugin_v2(BehaviorVersion::latest());
766
767 #[cfg(feature = "default-https-client")]
770 {
771 assert!(
772 old.is_some(),
773 "a pre-v2026_01_12 behavior version must fall back to the hyper 1.x client \
774 instead of getting no HTTP client"
775 );
776 assert!(
777 latest.is_some(),
778 "the latest behavior version must get the hyper 1.x client"
779 );
780 }
781
782 #[cfg(all(not(feature = "default-https-client"), feature = "tls-rustls"))]
785 assert!(
786 old.is_some(),
787 "a pre-v2026_01_12 behavior version must still get the legacy client when that is \
788 the only stack compiled in"
789 );
790
791 #[cfg(all(
793 not(feature = "default-https-client"),
794 not(feature = "connector-hyper-0-14-x")
795 ))]
796 {
797 assert!(
798 old.is_none(),
799 "no HTTP client stack is compiled in, so there is nothing to install"
800 );
801 assert!(
802 latest.is_none(),
803 "no HTTP client stack is compiled in, so there is nothing to install"
804 );
805 }
806
807 let _ = (old, latest);
808 }
809
810 #[test]
817 #[traced_test]
818 #[expect(deprecated)]
819 #[cfg(all(feature = "default-https-client", not(feature = "tls-rustls")))]
820 fn falling_back_to_the_hyper_1x_client_warns() {
821 let old = default_http_client_plugin_v2(BehaviorVersion::v2024_03_28());
822 assert!(old.is_some(), "the fallback should have supplied a client");
823 assert!(
824 logs_contain("selects the legacy hyper 0.14.x HTTP client"),
825 "falling back to the hyper 1.x client must be logged"
826 );
827 }
828
829 #[test]
835 #[traced_test]
836 #[expect(deprecated)]
837 #[cfg(feature = "tls-rustls")]
838 fn resolving_to_the_legacy_client_warns_that_the_default_is_changing() {
839 let old = default_http_client_plugin_v2(BehaviorVersion::v2024_03_28());
840 assert!(old.is_some(), "the legacy client should have been selected");
841 assert!(
842 logs_contain("the default becomes the hyper 1.x client"),
843 "resolving to the legacy client must announce the upcoming default change"
844 );
845 assert!(
846 logs_contain("legacy-https-client"),
847 "the warning must name the feature that pins the legacy client"
848 );
849 }
850
851 #[test]
854 #[traced_test]
855 #[expect(deprecated)]
856 #[cfg(all(
857 feature = "default-https-client",
858 not(feature = "connector-hyper-0-14-x")
859 ))]
860 fn a_build_without_the_legacy_client_does_not_warn_about_it() {
861 let _ = default_http_client_plugin_v2(BehaviorVersion::v2024_03_28());
862 assert!(
863 !logs_contain("the default becomes the hyper 1.x client"),
864 "a build with no legacy client must not warn about the legacy default changing"
865 );
866 }
867
868 #[test]
870 #[traced_test]
871 #[cfg(feature = "default-https-client")]
872 fn the_latest_behavior_version_does_not_warn() {
873 let latest = default_http_client_plugin_v2(BehaviorVersion::latest());
874 assert!(latest.is_some(), "the latest version should get a client");
875 assert!(
876 !logs_contain("selects the legacy hyper 0.14.x HTTP client"),
877 "the latest behavior version must not warn about the legacy stack"
878 );
879 }
880}