diff --git a/debian/changelog b/debian/changelog index 12bfdf3bac5ef87fd620c522ddf5fdff23384a87..0e68c13fc2151e7884a25b2e7276059acaf2d0fa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +autoradio (0.3.6p3) unstable; urgency=medium + + * Try harder to prevent caching of redirects. + + -- ale <ale@incal.net> Fri, 14 Nov 2014 13:01:26 +0000 + +autoradio (0.3.6p2) unstable; urgency=medium + + * Try to prevent caching of 302 responses. + + -- ale <ale@incal.net> Fri, 07 Nov 2014 15:33:26 +0000 + autoradio (0.3.6p1) unstable; urgency=medium * Increased burst size. diff --git a/fe/http.go b/fe/http.go index a0346d843dbf9bf7399ff06a44640a20aacaac22..ed0f7d82596e0c9bf45efe097488f0e29fcc8532 100644 --- a/fe/http.go +++ b/fe/http.go @@ -132,7 +132,8 @@ func (h *HttpRedirector) serveM3U(mount *autoradio.Mount, w http.ResponseWriter, // redirect replies to the request with a redirect to url, adding some // cache-busting headers. Code is mostly verbatim from net/http. -func redirect(w http.ResponseWriter, r *http.Request, urlStr string, code int) { +// Serve a 307 for HTTP/1.1 clients, a 302 otherwise. +func redirect(w http.ResponseWriter, r *http.Request, urlStr string) { if u, err := url.Parse(urlStr); err == nil { oldpath := r.URL.Path if oldpath == "" { @@ -161,7 +162,11 @@ func redirect(w http.ResponseWriter, r *http.Request, urlStr string, code int) { w.Header().Set("Location", urlStr) w.Header().Set("Cache-Control", "max-age=0,no-cache,no-store") w.Header().Set("Pragma", "no-cache") - w.Header().Set("Expires", "Thu, 1 Jan 1970 00:00:00 GMT") + w.Header().Set("Expires", "-1") + code := 302 + if r.ProtoMinor == 1 { + code = 307 + } w.WriteHeader(code) } @@ -180,7 +185,7 @@ func (h *HttpRedirector) serveRelay(mount *autoradio.Mount, w http.ResponseWrite h.serveM3U(mount, w, r) } else { targetURL := streamUrl(relayAddr, mount.Name) - redirect(w, r, targetURL, 302) + redirect(w, r, targetURL) } }