Skip to content

fix(resp): correct ConnectionUpgrade to check for Upgrade instead of keep-alive - #1537

Open
lxcxjxhx wants to merge 1 commit into
cloudwego:mainfrom
lxcxjxhx:fix/connection-upgrade-check
Open

fix(resp): correct ConnectionUpgrade to check for Upgrade instead of keep-alive#1537
lxcxjxhx wants to merge 1 commit into
cloudwego:mainfrom
lxcxjxhx:fix/connection-upgrade-check

Conversation

@lxcxjxhx

Copy link
Copy Markdown

What

Fix ConnectionUpgrade() in resp/header.go which was incorrectly checking for keep-alive instead of Upgrade in the Connection header.

Why

The function name and comment clearly state it should check for Connection: Upgrade, but the implementation was using bytestr.StrKeepAlive instead of bytestr.StrUpgrade.

This bug affects WebSocket support: when a response has Connection: Upgrade (as in WebSocket handshakes), ConnectionUpgrade() returns false, causing the code at line 204 to incorrectly set Transfer-Encoding: identity and close the connection.

Conversely, regular keep-alive responses would incorrectly trigger the upgrade path.

Changes

  • resp/header.go: change bytestr.StrKeepAlive to bytestr.StrUpgrade in ConnectionUpgrade()

Testing

go test ./pkg/protocol/http1/resp/...

All existing tests pass. This is a one-line bug fix.

…keep-alive

ConnectionUpgrade() was checking for the "keep-alive" value instead of
"Upgrade" in the Connection header. This caused WebSocket upgrade
responses to be incorrectly identified, potentially breaking WebSocket
support by setting Transfer-Encoding: identity and closing the connection.

Fix by using bytestr.StrUpgrade instead of bytestr.StrKeepAlive.
@CLAassistant

CLAassistant commented Aug 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants