all repos — homestead @ f77a047d541c8d394e712283ee33adeb75f3114d

Code for my website

fix and simplify content-encoding negotiation

Alan Pearce
commit

f77a047d541c8d394e712283ee33adeb75f3114d

parent

37a07480b19013b92c8cd851d507e622968fbb0b

1 file changed, 2 insertions(+), 4 deletions(-)

changed files
M internal/website/mux.gointernal/website/mux.go
@@ -80,15 +80,13 @@ w.Header().Add("Content-Security-Policy", cfg.CSP.String())
for k, v := range cfg.Extra.Headers { w.Header().Add(k, v) } - enc := nego.NegotiateContentEncoding(r, "br", "gzip") + enc := nego.NegotiateContentEncoding(r, file.AvailableEncodings()...) switch enc { - case "", "identity": - http.ServeFile(w, r, files[urlPath].filename) case "br", "gzip": w.Header().Add("Content-Encoding", enc) w.Header().Add("Content-Type", file.contentType) - http.ServeFile(w, r, files[urlPath].alternatives[enc]) } + http.ServeFile(w, r, files[urlPath].alternatives[enc]) return nil }))