diff options
| author | Shulhan <ms@kilabit.info> | 2021-12-19 01:33:12 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-12-19 02:13:57 +0700 |
| commit | ba9c2ea6bd2a3c39f20fe7b2cc702e7fd4c99c44 (patch) | |
| tree | b7f3db4fd854c186ed15da8dff7c8e8961b5ecc5 /lib/http | |
| parent | 9b8841034d7f4b6f92078f6dc682bd010fb37e72 (diff) | |
| download | pakakeh.go-ba9c2ea6bd2a3c39f20fe7b2cc702e7fd4c99c44.tar.xz | |
lib/memfs: remove field ContentEncoding from EmbedOptions and Node
The original idea for option ContentEncoding in EmbedOptions and Node
is to save spaces, compressing the content on disk on embedding and
doing transport, when the MemFS instance is used to serve the (embedded)
contents of file system.
This option turns out break the HTTP content negotiation [1] of
accept-encoding header, if the HTTP server does not handle it properly,
which default Go HTTP server does not.
In order to prevent this issue in the future, for anyone who use the
memfs for serving static HTTP contents, we remove the options and store
the embedded content as is and let the HTTP server handle how the
compression by itself.
[1] https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation
Diffstat (limited to 'lib/http')
| -rw-r--r-- | lib/http/server.go | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/lib/http/server.go b/lib/http/server.go index bccc098e..a3c4e474 100644 --- a/lib/http/server.go +++ b/lib/http/server.go @@ -494,10 +494,6 @@ func (srv *Server) HandleFS(res http.ResponseWriter, req *http.Request) { res.Header().Set(HeaderContentType, node.ContentType) - if len(node.ContentEncoding) > 0 { - res.Header().Set(HeaderContentEncoding, node.ContentEncoding) - } - responseETag := strconv.FormatInt(node.ModTime().Unix(), 10) requestETag := req.Header.Get(HeaderIfNoneMatch) if requestETag == responseETag { |
