dgrr / http2

HTTP/2 implementation for fasthttp
Apache License 2.0
210 stars 37 forks source link

read response body stream of fasthttp #42

Closed eole868 closed 2 years ago

eole868 commented 2 years ago

read response body stream when ctx.Response.IsBodyStream() is True, don't copy to resp.bodybuffer

example:

ctx.Response.SendFile("/path/file/")

ctx.Response.SetBodyStreamWriter(func(w *bufio.Writer) {
    buf := make([]byte, 4096)
    for {
            n, err := r.Read(buf)
                if n <= 0 || err != nil {
                    break;
                }
            w.Write(buf)
    }

})
dgrr commented 2 years ago

Thank you for your PR!