Try again to fix connection: upgrade bug
This commit is contained in:
parent
8c6114c3d3
commit
df4a36990c
1 changed files with 5 additions and 1 deletions
|
@ -52,8 +52,12 @@ fn copy_upgrade_headers(
|
||||||
old_headers: &HeaderMap<HeaderValue>,
|
old_headers: &HeaderMap<HeaderValue>,
|
||||||
new_headers: &mut HeaderMap<HeaderValue>,
|
new_headers: &mut HeaderMap<HeaderValue>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
|
// The Connection header is stripped as it is a hop header that we are not supposed to proxy.
|
||||||
|
// However, it might also contain an Upgrade directive, e.g. for Websockets:
|
||||||
|
// when that happen, we do want to preserve that directive.
|
||||||
if let Some(conn) = old_headers.get(header::CONNECTION) {
|
if let Some(conn) = old_headers.get(header::CONNECTION) {
|
||||||
if conn.to_str()?.to_lowercase() == "upgrade" {
|
let conn_str = conn.to_str()?.to_lowercase();
|
||||||
|
if conn_str.split(',').map(str::trim).any(|x| x == "upgrade") {
|
||||||
if let Some(upgrade) = old_headers.get(header::UPGRADE) {
|
if let Some(upgrade) = old_headers.get(header::UPGRADE) {
|
||||||
new_headers.insert(header::CONNECTION, "Upgrade".try_into()?);
|
new_headers.insert(header::CONNECTION, "Upgrade".try_into()?);
|
||||||
new_headers.insert(header::UPGRADE, upgrade.clone());
|
new_headers.insert(header::UPGRADE, upgrade.clone());
|
||||||
|
|
Loading…
Reference in a new issue