为什么客户端通过http.ServeContent读取我的视频时会继续关闭连接?

I am currently working on a small project for serving video to a browser or other media clients via http.ServeContent. I have implemented my own ReadSeeker which looks like this:

//the seek is not fully working yet but works fine for the initial two calls that is being called internally from http to decide the file size.

func (c *Client) Seek(offset int64, whence int) (t int64, e error) {
    switch whence {
    case 0:
        t = offset
    case 1:
        t = c.seek + offset
    case 2:
        t = c.SelectedFile().Length + offset
    }

    if c.seek != t {
        //TODO
        c.seek = t
    }

    return
}

func (c *Client) Read(p []byte) (n int, err error) {
    if c.done {
        return 0, io.EOF
    }

    for {
        result := <-c.Results

        if result.piece == nil {
            return 0, io.EOF
        }

        for i, b := range result.bytes {
            index := int64(i)
            if index < 0 || index > c.SelectedFile().Length {
                continue
            }

            n++
            p[index] = b
        }

        return
    }
}

Everything works fine and dandy if I for instance use curl to fetch the data eg data keeps being streamed (1024 bytes per read). However as soon as I use a browser or even VLC, after between 5 to 10 reads the http writer.Write() returns an EPIPE error and the connection is broken. The error appear to come directly from dst.Write(buf[0:nr]) inside io.go :

...
func copyBuffer(dst Writer, src Reader, buf []byte) (written int64, err error) {
    ...
    for {
        nr, er := src.Read(buf)
        if nr > 0 {
            nw, ew := dst.Write(buf[0:nr])
            if nw > 0 {
                written += int64(nw)
            }
            if ew != nil {
                err = ew
                break
            }
            if nr != nw {
                err = ErrShortWrite
                break
            }
        }
        if er != nil {
            if er != EOF {
                err = er
            }
            break
        }
    }
    return written, err
}

I have tried to debug for days now and can't seem to figure out the cause. I've been comparing the bytes I serve with the actual file and it does not not seem to be anything wrong with the data.

Any ideas what might be wrong?

Nothing is wrong. There is nothing that requires the client to not disconnect until the server has sent all the data. It is very common, especially for mp4 files, for the client to perform a standard http request, then cancel after it has received the headers.

I suspect however the video is not playing they way you expect? If that is the case, make sure your server implements http range requests.