š [Proposal]: Add support for fasthttp.StreamResponseBody
Feature Proposal Description
FastHTTP added support for StreamResponseBody back in 2022 but it was never added to Fiber. The proposal is to make this option available in the Fiber Client and any other places it applies.
Related PR: https://github.com/valyala/fasthttp/pull/1414
Alignment with Express API
N/a
HTTP RFC Standards Compliance
N/a
API Stability
N/a
Feature Examples
req := fasthttp.AcquireRequest()
resp := fasthttp.AcquireResponse()
defer fasthttp.ReleaseRequest(req)
defer fasthttp.ReleaseResponse(resp)
client := &fasthttp.Client{
StreamResponseBody: true,
}
req.SetRequestURI("http://example.com/sse")
req.Header.SetMethod("GET")
req.Header.Set("Accept", "text/event-stream")
err := client.Do(req, resp)
if err != nil {
log.Fatal(err)
}
reader := bufio.NewReader(resp.BodyStream())
for {
line, err := reader.ReadString('\n')
if err != nil {
if err == io.EOF {
break
}
log.Fatal(err)
}
fmt.Print("Received:", line)
}
Checklist:
- [x] I agree to follow Fiber's Code of Conduct.
- [x] I have searched for existing issues that describe my proposal before opening this one.
- [x] I understand that a proposal that does not meet these guidelines may be closed without explanation.
Hey @gaby Iād love to work on this ā please assign it to me
@satti-hari-krishna-reddy Target branch is main. Thanks!
@satti-hari-krishna-reddy Any updates on this?
@gaby Hello, I'm quite interested in this issue. However, I noticed that the Client struct has already encapsulated the *fasthttp.Client struct, right? Shouldn't setting the StreamResponseBody of *fasthttp.Client to true directly achieve this functionality?
@gaby is this issue still up for grabs?
@Abhirup-99 Yes