Clear Content-Length header from redirected requests (#394)

This PR removes the Content-Length header from subsequent redirect requests if set.
A test verifies the new behaviour.
This commit is contained in:
Gus Power
2021-06-19 00:12:31 +01:00
committed by GitHub
parent 989995d1ba
commit 37e1e91e22
2 changed files with 19 additions and 0 deletions

View File

@@ -205,6 +205,8 @@ pub(crate) fn connect(
debug!("redirect {} {} -> {}", resp.status(), url, new_url);
history.push(unit.url.to_string());
body = Payload::Empty.into_read();
unit.headers.retain(|h| h.name() != "Content-Length");
// recreate the unit to get a new hostname and cookies for the new host.
unit = Unit::new(
&unit.agent,