Skip to content

Commit

Permalink
Merge pull request #110 from sonroyaalmerol/flush-buffer
Browse files Browse the repository at this point in the history
Clear buffer and flush out writer on return
  • Loading branch information
sonroyaalmerol committed Aug 25, 2024
2 parents 5dbc7d8 + 02ad7c1 commit 5d6d841
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions stream_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ func proxyStream(m3uIndex int, resp *http.Response, r *http.Request, w http.Resp
buffer = make([]byte, bufferMbInt*1024*1024)
}

defer func() {
buffer = nil
if flusher, ok := w.(http.Flusher); ok {
flusher.Flush()
}
}()

for {
n, err := resp.Body.Read(buffer)
if err != nil {
Expand Down

0 comments on commit 5d6d841

Please sign in to comment.