Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols
9.74k
stars
1.09k
forks
source link
[TT-13257] Websocket connection is not upgraded when `keep-alive` is added to Connection #6449
Open
Darkness4 opened 3 months ago
Branch/Environment/Version
Describe the bug Connection header is deleted and not upgraded even if
Upgrade
is present, but with otherConnection
likekeep-alive
:This notably affects Firefox users when trying to dial the tyk gateway.
Reproduction steps Steps to reproduce the behavior:
Test case
Added a test at
gateway/gateway_test.go
.Via Firefox
Firefox send a
Connection: Upgrade, keep-alive
when trying to connect to a websocket (GraphQL).Actual behavior
Test panic. By applying a debug at https://github.com/TykTechnologies/tyk/blob/2a2a98461d86bd352aa8bb3b8904a62cca42c167/gateway/testutil.go#L461-L464.
It prints:
Connection header has been filtered and the connection is not upgraded (conn is nil), causing a panic in the test case.
Expected behavior
Connection should be upgraded and the header should be passed.
Cause
https://github.com/TykTechnologies/tyk/blob/2a2a98461d86bd352aa8bb3b8904a62cca42c167/internal/httputil/streaming.go#L25-L37
Detections of "upgrade" in "Connection" header is too strict (
!=
) and should be more flexible (not contains
).Possible solutions
Using nhooyr.io's implementation style:
Nhooyr implementation seems pretty standard while gorilla/websocket seems "home-made".
If you could please fix this as this literally block all firefox users in using WS (including GraphQL subscriptions). Thank you :pray: .