Closed dgrr closed 4 years ago
No. I want to do in a client, to receive an amount of data greater than 10MB and don't store it in memory
I'm afraid fasthttp doesn't support that. The only thing you can do is set MaxResponseBodySize but this will just abort the request once the size is reached.
The main problem is that fasthttp load all content in memory buffer and then you can handle as you want. I think we can implement some io.Reader/Writer to read or write the body request/response. My final intention is to store and handle big files without storing in memory. Any proposal how to do that?
Client
uses Response.ReadLimitBody
to read the response body. This method then allocates a bytebufferpool.ByteBuffer
and calls readBody
which then calls one of 3 method depending on the encoding of the body.
Right now readBody
and the method it calls directly use ByteBuffer.B
. If you could change these methods to accept an io.Writer
/io.ReaderFrom
combination of some sorts (that bytebufferpool.ByteBuffer
already implements) you could add an extra argument to Client
to provide your own (instead of the one readBody
allocates).
Um, and what about func GetBody() io.Reader
as https://godoc.org/net/http#Request? We can implement something like this
No that's not possible as Client
already fetches the body in Client.Do
. It needs to be either an io.Writer/io.ReaderFrom
or callback function set somewhere. It could be in Client
but this would mean all requests use the same function and wouldn't be really safe. Or it could be set in Request
or Response
. I'm not sure what is best and easiest.
Hello.
Fasthttp allows to set response reader of body like net/http package?