Open
Description
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: valyala/fasthttp#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:
- I agree to follow Fiber's Code of Conduct.
- I have searched for existing issues that describe my proposal before opening this one.
- I understand that a proposal that does not meet these guidelines may be closed without explanation.
Metadata
Metadata
Assignees
Type
Projects
Status
Todo