Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
reverseproxy: Ignore RFC 1521 params in Content-Type header (#3758)
Without this change, a Content-Type header like "text/event-stream;charset=utf-8" would not trigger the immediate flushing. Fixes #3765
Christian Flach committed
Oct 1, 2020 at 20:15 UTC
fdfdc033392d6bcc8c98232d5db825fcf4b78a51
1 file changed
+4
-2
modules/caddyhttp/reverseproxy/streaming.go
+4
-2
@@ -21,6 +21,7 @@ package reverseproxy
21
import (
22
"context"
23
"io"
24
+ "mime"
25
"net/http"
26
"sync"
27
"time"
@@ -88,11 +89,12 @@ func (h Handler) handleUpgradeResponse(rw http.ResponseWriter, req *http.Request
89
// flushInterval returns the p.FlushInterval value, conditionally
90
// overriding its value for a specific request/response.
91
func (h Handler) flushInterval(req *http.Request, res *http.Response) time.Duration {
91
- resCT := res.Header.Get("Content-Type")
92
+ resCTHeader := res.Header.Get("Content-Type")
93
+ resCT, _, err := mime.ParseMediaType(resCTHeader)
94
95
// For Server-Sent Events responses, flush immediately.
96
// The MIME type is defined in https://www.w3.org/TR/eventsource/#text-event-stream
95
- if resCT == "text/event-stream" {
97
+ if err == nil && resCT == "text/event-stream" {
98
return -1 // negative means immediately
99
}
100