Skip to content

Reuse body for response #1811

@megashchik-old

Description

@megashchik-old

Greetings!

I have the following problem
I have a fairly heavy query, the answer to which takes up a lot of space
I would like to reuse the buffer for it
This can be done via fasthttp.Post, but you cannot insert a complex request with headers there

It seems like the solution would be something like this

 req := fasthttp.AcquireRequest()
 resp := fasthttp.AcquireResponse()
 defer fasthttp.ReleaseRequest(req)
 defer fasthttp.ReleaseResponse(resp)
 // set headers
 resp.KeepBodyBuffer = true
 err = fasthttp.Do(req, resp)
 if err != nil {
   return err
 }
 resp.KeepBodyBuffer = false
 ...

However, the keepBodyBuffer field is private

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions