Closed
Description
What version of Go are you using (go version
)?
go version go1.8 darwin/amd64
What did you do?
I've tried to transcode and serve/stream a video file in the same time. Below is some pseudo code.
go func(){
// convert the video file in a format supported by the browser
transcode(fromFilePath, toFilePath)
()
// serve the content while transcoding takes place.
f, _ := os.OpenFile(toFilePath, os.O_RDONLY, 0666)
http.ServeContent(w, r, toFilePath, time.Now(), f)
What did you expect to see?
Serve the file in chunks as the file grows/is transcoded.
What did you see instead?
ServeContent writes several headers such Content-Length even we don't know the length of the file when transcoding is complete and serves/writes only the content already transcoded at the time the request is made is served.
The solution could be to use Chunked transfer encoding .