summaryrefslogtreecommitdiffhomepage
path: root/tsweb/tsweb.go
diff options
context:
space:
mode:
authorJames Tucker <james@tailscale.com>2022-11-30 13:43:30 -0800
committerJames Tucker <james@tailscale.com>2022-11-30 13:49:04 -0800
commit08a34edd91d85489666288203ab25f86f478043f (patch)
tree264d3ee5826a2e4685111f7f970ed1bbdc450970 /tsweb/tsweb.go
parent9a80b8fb10bb6ccbbd28082dd70620b46f5e6da9 (diff)
downloadtailscale-raggi/tsweb-compression.tar.xz
tailscale-raggi/tsweb-compression.zip
tsweb: add transparent compression for StdHandlerraggi/tsweb-compression
Implements inline compression for both gzip and brotli via the brotli library. The library requires that Content-Type is set. The implementation here explicitly avoids wrapping the ResponseWriter in cases where Accept-Encoding is not set so as to maximally attempt to get out of the way of hijack and upgrade concerns. It also avoids any attempt at compression if Content-Encoding is already set so that handlers that already perform compression are unaffected. Signed-off-by: James Tucker <james@tailscale.com>
Diffstat (limited to 'tsweb/tsweb.go')
-rw-r--r--tsweb/tsweb.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/tsweb/tsweb.go b/tsweb/tsweb.go
index 8b52e656d..ac6a14332 100644
--- a/tsweb/tsweb.go
+++ b/tsweb/tsweb.go
@@ -239,7 +239,7 @@ func StdHandler(h ReturnHandler, opts HandlerOptions) http.Handler {
if opts.Logf == nil {
opts.Logf = logger.Discard
}
- return retHandler{h, opts}
+ return compressingHandler{retHandler{h, opts}}
}
// retHandler is an http.Handler that wraps a Handler and handles errors.