Skip to content
10 changes: 6 additions & 4 deletions tower-http/src/follow_redirect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
//! redirections.
//!
//! The middleware tries to clone the original [`Request`] when making a redirected request.
//! However, since [`Extensions`][http::Extensions] are `!Clone`, any extensions set by outer
//! middleware will be discarded. Also, the request body cannot always be cloned. When the
//! However, the request body cannot always be cloned. When the
//! original body is known to be empty by [`Body::size_hint`], the middleware uses `Default`
//! implementation of the body type to create a new request body. If you know that the body can be
//! cloned in some way, you can tell the middleware to clone it by configuring a [`policy`].
Expand Down Expand Up @@ -98,8 +97,8 @@ use self::policy::{Action, Attempt, Policy, Standard};
use futures_util::future::Either;
use http::{
header::CONTENT_ENCODING, header::CONTENT_LENGTH, header::CONTENT_TYPE, header::LOCATION,
header::TRANSFER_ENCODING, HeaderMap, HeaderValue, Method, Request, Response, StatusCode, Uri,
Version,
header::TRANSFER_ENCODING, Extensions, HeaderMap, HeaderValue, Method, Request, Response,
StatusCode, Uri, Version,
};
use http_body::Body;
use iri_string::types::{UriAbsoluteString, UriReferenceStr};
Expand Down Expand Up @@ -219,6 +218,7 @@ where
uri: req.uri().clone(),
version: req.version(),
headers: req.headers().clone(),
extensions: req.extensions().clone(),
body,
future: Either::Left(service.call(req)),
service,
Expand All @@ -242,6 +242,7 @@ pin_project! {
uri: Uri,
version: Version,
headers: HeaderMap<HeaderValue>,
extensions: Extensions,
body: BodyRepr<B>,
}
}
Expand Down Expand Up @@ -322,6 +323,7 @@ where
*req.method_mut() = this.method.clone();
*req.version_mut() = *this.version;
*req.headers_mut() = this.headers.clone();
*req.extensions_mut() = this.extensions.clone();
this.policy.on_request(&mut req);
this.future
.set(Either::Right(Oneshot::new(this.service.clone(), req)));
Expand Down