SplitHTTP: Fix connection leaks and crashes (#3710)

This commit is contained in:
mmmray 2024-08-22 17:07:57 +02:00 committed by GitHub
parent 2be03c56cb
commit 83eef6bc1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 109 additions and 65 deletions

View file

@ -222,8 +222,12 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req
h.ln.addConn(stat.Connection(&conn))
// "A ResponseWriter may not be used after [Handler.ServeHTTP] has returned."
<-downloadDone.Wait()
select {
case <-request.Context().Done():
case <-downloadDone.Wait():
}
conn.Close()
} else {
writer.WriteHeader(http.StatusMethodNotAllowed)
}