Correct cookie concatenation

This commit is contained in:
Alex 2022-02-27 19:53:06 +01:00
parent d85ef18269
commit 4ba13a3fcb
Signed by: lx
GPG key ID: 0E496D15096376BE

View file

@ -84,16 +84,16 @@ fn create_proxied_request<B>(
}
// Concatenate cookie headers into single header
// (HTTP/2 allows several cookie headers, but we are proxying to
// HTTP/1.1 that does not)
// (HTTP/2 allows several cookie headers, but we are proxying to HTTP/1.1 that does not)
let mut cookie_concat = vec![];
while let Some(cookie) = headers.remove(header::COOKIE) {
for cookie in headers.get_all(header::COOKIE) {
if !cookie_concat.is_empty() {
cookie_concat.extend(b"; ");
}
cookie_concat.extend_from_slice(cookie.as_bytes());
}
if !cookie_concat.is_empty() {
// insert clears the old value of COOKIE and inserts the concatenated version instead
headers.insert(header::COOKIE, cookie_concat.try_into()?);
}