Similar idea as #16640, with a slightly different approach in relation with Go.
The generated client only gives the option to stream bodies to memory via io.ReadAll. It doesn't give the option to stream the body to any other form (e.g. to disk).
Describe the solution you'd like
- Have the Execute functions avoid calling
io.ReadAll unless the content-type is json, xml, etc.
- For example, if the content-type returns as octet-stream or similar, don't call
io.ReadAll and have those using this manually handle it using the *http.Response return value.
- Add a new function for each Execute called
ExecuteNoRead or ExecuteWithBody; the idea is Execute will stay the same while the new function will always only return the (*http.Response, error) tuple.
- In this case, calling Execute will always stream the entire body to memory, while the new function will give the users control over the response body.
Describe alternatives you've considered
I've been using raw HTTP requests using Go's standard library via net/http, having it return bodies yet to be streamed. I've also tried my own implementation for this issue (specifically solution 2), and it seems to run great with my projects.
Similar idea as #16640, with a slightly different approach in relation with Go.
The generated client only gives the option to stream bodies to memory via
io.ReadAll. It doesn't give the option to stream the body to any other form (e.g. to disk).Describe the solution you'd like
io.ReadAllunless the content-type is json, xml, etc.io.ReadAlland have those using this manually handle it using the*http.Responsereturn value.ExecuteNoReadorExecuteWithBody; the idea is Execute will stay the same while the new function will always only return the(*http.Response, error)tuple.Describe alternatives you've considered
I've been using raw HTTP requests using Go's standard library via
net/http, having it return bodies yet to be streamed. I've also tried my own implementation for this issue (specifically solution 2), and it seems to run great with my projects.