How to read response's body without copying buffer
See original GitHub issueHey guys
I had to do something like response.body().bytes()
in an Interceptor, then had to recreate a full Response with the fetched byte to return a clean Request that can be parsed again, instead of just switching the Reader Index back to it’s beginning. That’s a lot of temporary objects to garbage-collect.
Do you have a better solution?
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How to Read a http Response body to buffer in golang(without ...
You can use io.Copy which takes io.Writer and io.Reader . io.Copy uses 32KB buffer to copy from reader to writer until it reaches...
Read more >Re-reading ASP.Net Core request bodies with EnableBuffering()
A straightforward solution is to save a copy of the stream in another stream that supports seeking so the content can be read...
Read more >Should response Body be fully read for HTTP connection re ...
I think it does get read implicitly if it fits entirely in the read buffer, but there's no guarantee.
Read more >Response.arrayBuffer() - Web APIs - MDN Web Docs
When the fetch is successful, we read an ArrayBuffer out of the response using arrayBuffer() , decode the audio data using AudioContext.
Read more >How to convert an HTTP response body to a string in Go
ReadAll() in Go 1.15 and earlier) to read the whole body into a slice ... or just the response headers (without the body),...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So basically, it would look like this?
Will this solution also work with multipart requests?
I’m using Jackson’s ObjectMapper
readValue
that can accepts both abyte[]
or aString
.Should I simply call
snapshot().utf8()
?internalArray()
is package-protected