mirror of https://github.com/gofiber/fiber.git
fix `ctx.SendStream(io.Reader)` huge memory usage (#2091)
* Update ctx.go * remove content-length from testpull/2095/head
parent
8ec62a64cc
commit
709c52301c
1
ctx.go
1
ctx.go
|
@ -1545,7 +1545,6 @@ func (c *Ctx) SendStream(stream io.Reader, size ...int) error {
|
|||
c.fasthttp.Response.SetBodyStream(stream, size[0])
|
||||
} else {
|
||||
c.fasthttp.Response.SetBodyStream(stream, -1)
|
||||
c.setCanonical(HeaderContentLength, strconv.Itoa(len(c.fasthttp.Response.Body())))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -3302,11 +3302,6 @@ func Test_Ctx_SendStream(t *testing.T) {
|
|||
|
||||
c.SendStream(bufio.NewReader(bytes.NewReader([]byte("Hello bufio"))))
|
||||
utils.AssertEqual(t, "Hello bufio", string(c.Response().Body()))
|
||||
|
||||
file, err := os.Open("./.github/index.html")
|
||||
utils.AssertEqual(t, nil, err)
|
||||
c.SendStream(bufio.NewReader(file))
|
||||
utils.AssertEqual(t, true, c.Response().Header.ContentLength() > 200)
|
||||
}
|
||||
|
||||
// go test -run Test_Ctx_Set
|
||||
|
|
Loading…
Reference in New Issue