summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Flach <cmfcmf.flach@gmail.com>2020-10-01 20:15:45 +0200
committerGitHub <noreply@github.com>2020-10-01 12:15:45 -0600
commitfdfdc033392d6bcc8c98232d5db825fcf4b78a51 (patch)
treeb3eed194f00549901d85f8d3d9fd6714c25429e9
parentdadfe1933b4ddab649b1bd64563eb8a0e4142979 (diff)
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
-rw-r--r--modules/caddyhttp/reverseproxy/streaming.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/caddyhttp/reverseproxy/streaming.go b/modules/caddyhttp/reverseproxy/streaming.go
index 666cf48..d183244 100644
--- a/modules/caddyhttp/reverseproxy/streaming.go
+++ b/modules/caddyhttp/reverseproxy/streaming.go
@@ -21,6 +21,7 @@ package reverseproxy
import (
"context"
"io"
+ "mime"
"net/http"
"sync"
"time"
@@ -88,11 +89,12 @@ func (h Handler) handleUpgradeResponse(rw http.ResponseWriter, req *http.Request
// flushInterval returns the p.FlushInterval value, conditionally
// overriding its value for a specific request/response.
func (h Handler) flushInterval(req *http.Request, res *http.Response) time.Duration {
- resCT := res.Header.Get("Content-Type")
+ resCTHeader := res.Header.Get("Content-Type")
+ resCT, _, err := mime.ParseMediaType(resCTHeader)
// For Server-Sent Events responses, flush immediately.
// The MIME type is defined in https://www.w3.org/TR/eventsource/#text-event-stream
- if resCT == "text/event-stream" {
+ if err == nil && resCT == "text/event-stream" {
return -1 // negative means immediately
}