Fix WriteHeader order.

This commit is contained in:
2024-08-14 18:17:46 +08:00
parent 186b714a65
commit 075dabcec8
+4 -2
View File
@@ -205,16 +205,18 @@ func clientHandler(w http.ResponseWriter, r *http.Request) {
http.NotFound(w, r) http.NotFound(w, r)
return return
} }
if r.Method == http.MethodHead {
w.Header().Add("Content-Type", "video/MP2T") w.Header().Add("Content-Type", "video/MP2T")
w.WriteHeader(200) w.WriteHeader(200)
if r.Method == http.MethodHead {
// Fuck you golang, you should never eat write but fail // Fuck you golang, you should never eat write but fail
return return
} }
if r.Method != http.MethodGet { if r.Method != http.MethodGet {
w.WriteHeader(405) http.Error(w, "405 method not allowed", 405)
return return
} }
w.Header().Add("Content-Type", "video/MP2T")
w.WriteHeader(200)
ch := NewClientChannel(name) ch := NewClientChannel(name)
defer ch.Close() defer ch.Close()
for { for {