Skip to content

Commit 8c8c7a4

Browse files
authored
Merge pull request #7 from roblaszczak/master
Fixed RFC7540 (HTTP2) combatiliby
2 parents 7bbdb19 + bf08e89 commit 8c8c7a4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

responder.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,13 @@ func channelEventStream(w http.ResponseWriter, r *http.Request, v interface{}) {
146146

147147
w.Header().Set("Content-Type", "text/event-stream; charset=utf-8")
148148
w.Header().Set("Cache-Control", "no-cache")
149-
w.Header().Set("Connection", "keep-alive")
149+
150+
if r.ProtoMajor == 1 {
151+
// An endpoint MUST NOT generate an HTTP/2 message containing connection-specific header fields.
152+
// Source: RFC7540
153+
w.Header().Set("Connection", "keep-alive")
154+
}
155+
150156
w.WriteHeader(200)
151157

152158
ctx := r.Context()

0 commit comments

Comments
 (0)