mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-12-06 12:04:22 +00:00
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.
16 lines
593 B
Go
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/")
|
|
}
|