1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00

document new body map types

This commit is contained in:
Rob Ede
2022-01-23 23:26:35 +00:00
parent 008753f07a
commit 50894e392e
8 changed files with 29 additions and 26 deletions

View File

@ -94,10 +94,9 @@ impl Client {
let mut req = ClientRequest::new(method, url, self.0.clone());
for header in self.0.default_headers.iter() {
// header map is empty
// TODO: probably append instead
req = req.insert_header_if_none(header);
req = req.append_header(header);
}
req
}

View File

@ -163,7 +163,7 @@ where
| StatusCode::PERMANENT_REDIRECT
if *max_redirect_times > 0 =>
{
let is_redirect = res.head().status == StatusCode::TEMPORARY_REDIRECT
let reuse_body = res.head().status == StatusCode::TEMPORARY_REDIRECT
|| res.head().status == StatusCode::PERMANENT_REDIRECT;
let prev_uri = uri.take().unwrap();
@ -176,7 +176,7 @@ where
let connector = connector.take();
// reset method
let method = if is_redirect {
let method = if reuse_body {
method.take().unwrap()
} else {
let method = method.take().unwrap();
@ -187,18 +187,19 @@ where
};
let mut body = body.take();
let body_new = if is_redirect {
// try to reuse body
let body_new = if reuse_body {
// try to reuse saved body
match body {
Some(ref bytes) => AnyBody::Bytes {
body: bytes.clone(),
},
// TODO: should this be AnyBody::Empty or AnyBody::None.
// body was a non-reusable type so send an empty body instead
_ => AnyBody::empty(),
}
} else {
body = None;
// remove body
// remove body since we're downgrading to a GET
AnyBody::None
};