diff options
| author | James Harris <mailjamesharris@gmail.com> | 2021-09-17 02:29:00 +0000 |
|---|---|---|
| committer | Damien Neil <dneil@google.com> | 2021-10-13 17:16:12 +0000 |
| commit | 4a3daeee636751a262eb9f77d8e90c59955ee6bb (patch) | |
| tree | 0b3b7026676a7f7020fd18cf053b4da251a985d8 /src/net/http/httputil/reverseproxy_test.go | |
| parent | b5904f3de0937aac72acd40d6c26494ebb9d7909 (diff) | |
| download | go-4a3daeee636751a262eb9f77d8e90c59955ee6bb.tar.xz | |
net/http/httputil: allow MIME parameters when detecting SSE in ReverseProxy
This change allows httputil.ReverseProxy to detect SSE (server-sent events)
content when the response's Content-Type header includes MIME parameters,
such as "text/event-stream;charset=utf-8".
Prior to this change the value of the Content-Type header was compared
directly to the literal "text/event-stream". This caused a false-negative
which failed to set the FlushInterval correctly when MIME parameters were
present.
Change-Id: If8bb43efb78787b6519d7fe7599ca018a0da0023
GitHub-Last-Rev: 224518c5eb9686ee050c79f5f853ebacfdf6fc42
GitHub-Pull-Request: golang/go#48427
Reviewed-on: https://go-review.googlesource.com/c/go/+/350509
Trust: Alexander Rakoczy <alex@golang.org>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Diffstat (limited to 'src/net/http/httputil/reverseproxy_test.go')
| -rw-r--r-- | src/net/http/httputil/reverseproxy_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/net/http/httputil/reverseproxy_test.go b/src/net/http/httputil/reverseproxy_test.go index 4b6ad77a29..90e8903e9c 100644 --- a/src/net/http/httputil/reverseproxy_test.go +++ b/src/net/http/httputil/reverseproxy_test.go @@ -1195,6 +1195,26 @@ func TestSelectFlushInterval(t *testing.T) { want: -1, }, { + name: "server-sent events with media-type parameters overrides non-zero", + res: &http.Response{ + Header: http.Header{ + "Content-Type": {"text/event-stream;charset=utf-8"}, + }, + }, + p: &ReverseProxy{FlushInterval: 123}, + want: -1, + }, + { + name: "server-sent events with media-type parameters overrides zero", + res: &http.Response{ + Header: http.Header{ + "Content-Type": {"text/event-stream;charset=utf-8"}, + }, + }, + p: &ReverseProxy{FlushInterval: 0}, + want: -1, + }, + { name: "Content-Length: -1, overrides non-zero", res: &http.Response{ ContentLength: -1, |
