Reports whether a set of request headers describes an RFC 6455 WebSocket
upgrade.
Both conditions are required, per RFC 6455 §4.2.1: Upgrade must equal
websocket (case-insensitively), and Connection must contain the
upgrade token. Connection is a comma-separated list — proxies routinely
send keep-alive, Upgrade — so it is matched token-wise rather than by
substring, which would also match a header value such as no-upgrade.
Lives here rather than in @setu-ts/runtime because the kernel decides
whether a request is an upgrade (after the pipeline runs) while the adapters
still need the identical rule, and the kernel does not depend on the runtime
package. A pure predicate is exactly what common is for (AI_GUIDELINES
§2.1); @setu-ts/runtime re-exports this one rather than keeping a second
copy (§11.1).
Parameters
headers: Headers
The request headers
Returns boolean
true when the request asks for a WebSocket upgrade
Example
if (isWebSocketUpgradeRequest(request.headers)) { // consult the upgrade router }
Reports whether a set of request headers describes an RFC 6455 WebSocket upgrade.
Both conditions are required, per RFC 6455 §4.2.1:
Upgrademust equalwebsocket(case-insensitively), andConnectionmust contain theupgradetoken.Connectionis a comma-separated list — proxies routinely sendkeep-alive, Upgrade— so it is matched token-wise rather than by substring, which would also match a header value such asno-upgrade.Lives here rather than in
@setu-ts/runtimebecause the kernel decides whether a request is an upgrade (after the pipeline runs) while the adapters still need the identical rule, and the kernel does not depend on the runtime package. A pure predicate is exactly whatcommonis for (AI_GUIDELINES §2.1);@setu-ts/runtimere-exports this one rather than keeping a second copy (§11.1).