Files
MrAlders0n 695cbbe2aa fix(ws): send Safari and iOS clients uncompressed frames
iOS WebKit drops the socket on the first permessage-deflate message, so every iPhone and iPad browser reconnected about every 0.1 s since 2.1.0. Compress only for Chromium, Firefox and the app.
2026-10-31 16:40:19 -04:00

16 lines
593 B
Go

// Copyright 2026 Beacon Contributors
// SPDX-License-Identifier: AGPL-3.0-or-later
package ws
import "strings"
// compressesFor reports whether a client gets permessage-deflate. iOS WebKit (every iPhone and iPad
// browser) drops the socket on the first compressed message, and an iPad in desktop mode looks like
// Mac Safari, so only clients known to read it are compressed: Chromium, Firefox and the app.
func compressesFor(userAgent string) bool {
return strings.HasPrefix(userAgent, "Dart/") ||
strings.Contains(userAgent, "Chrome/") ||
strings.Contains(userAgent, "Firefox/")
}