Fix status code write
This commit is contained in:
parent
7c38374d99
commit
6401a214ec
|
@ -154,10 +154,14 @@ func (c *FastHTTPContext) ServeStream(stream Stream) {
|
|||
c.SetResponseCode(fasthttp.StatusPartialContent)
|
||||
c.SetResponseHeader("Content-Range", fmt.Sprintf("bytes %d-%d/%d", rangeStart, rangeStart+rangeLength-1, size))
|
||||
size = rangeLength
|
||||
} else {
|
||||
|
||||
c.SetResponseCode(fasthttp.StatusOK)
|
||||
}
|
||||
|
||||
c.ctx.SetBodyStream(stream, int(size))
|
||||
} else {
|
||||
c.SetResponseCode(fasthttp.StatusOK)
|
||||
c.ctx.SetBodyStream(stream, -1)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,17 +152,22 @@ func (c *NetHTTPContext) ServeStream(stream Stream) {
|
|||
return
|
||||
}
|
||||
|
||||
c.SetResponseCode(fasthttp.StatusPartialContent)
|
||||
c.SetResponseHeader("Content-Length", strconv.FormatInt(size, 10))
|
||||
c.SetResponseHeader("Content-Range", fmt.Sprintf("bytes %d-%d/%d", rangeStart, rangeStart+rangeLength-1, size))
|
||||
c.SetResponseCode(fasthttp.StatusPartialContent)
|
||||
size = rangeLength
|
||||
} else {
|
||||
c.SetResponseHeader("Content-Length", strconv.FormatInt(size, 10))
|
||||
c.SetResponseCode(fasthttp.StatusOK)
|
||||
}
|
||||
|
||||
c.SetResponseHeader("Content-Length", strconv.FormatInt(size, 10))
|
||||
|
||||
if !c.IsHead() {
|
||||
io.CopyN(c.httpWriter, dstream, size)
|
||||
}
|
||||
} else {
|
||||
|
||||
c.SetResponseCode(fasthttp.StatusOK)
|
||||
|
||||
if !c.IsHead() {
|
||||
c.SetResponseHeader("Transfer-Encoding", "chunked")
|
||||
io.Copy(c.httpWriter, dstream)
|
||||
|
|
Loading…
Reference in a new issue