Workaround a bug causing Firefox 61-62 to reject responses with Content-Type = application/dns-message

This commit is contained in:
Star Brilliant 2018-07-02 17:55:58 +08:00
parent e19250dc99
commit 7e7cd1ee90

View File

@ -192,6 +192,8 @@ func (s *Server) patchDNSCryptProxyReqID(w http.ResponseWriter, r *http.Request,
// Workaround a bug causing Firefox 61-62 to reject responses with Content-Type = application/dns-message
func (s *Server) patchFirefoxContentType(w http.ResponseWriter, r *http.Request) bool {
if strings.Contains(r.UserAgent(), "Firefox") && strings.Contains(r.Header.Get("Accept"), "application/dns-udpwireformat") && !strings.Contains(r.Header.Get("Accept"), "application/dns-message") {
log.Println("Firefox 61-62 detected. Patching response.")
w.Header().Set("Vary", "Accept, User-Agent")
w.Header().Set("Content-Type", "application/dns-udpwireformat")
return true
}