Merge pull request 'reverse proxy: also add tag-based headers for redirections' (#17) from Armael/tricot:headers_for_redirects into main

Reviewed-on: Deuxfleurs/tricot#17
This commit is contained in:
Armael 2024-12-01 15:31:13 +00:00
commit 2a679f97b6

View file

@ -371,8 +371,8 @@ async fn do_proxy(
reverse_proxy::call(remote_addr.ip(), &to_addr, req).await? reverse_proxy::call(remote_addr.ip(), &to_addr, req).await?
}; };
if response.status().is_success() { if response.status().is_success() || response.status().is_redirection() {
// (TODO: maybe we want to add these headers even if it's not a success?) // (TODO: maybe we want to add these headers even if it's not a success or redirection?)
for (header, value) in proxy_to.add_headers.iter() { for (header, value) in proxy_to.add_headers.iter() {
response.headers_mut().insert( response.headers_mut().insert(
HeaderName::from_bytes(header.as_bytes())?, HeaderName::from_bytes(header.as_bytes())?,