-
-
Notifications
You must be signed in to change notification settings - Fork 243
Description
Currently, response body is read entirely and closed inside Response constructor. This prevents Response to work with stream responses, e.g. SSE.
To fix this, Response should not read entire body in constructor, but instead read it only on demand when it's needed first time, e.g. when the user invoked Text() or JSON(). This way it'll continue to work as before for regular responses and wont break with stream responses, given that the user does not try to invoke inappropriate methods on them.
We need to find all places when r.content
is used in response.go and replace it with a function call which will check if response body is already read, and read it if necessary.
We should add unit test for Response that checks that body is not read until a call to Text/JSON/etc.