You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 15, 2021. It is now read-only.
Body data can only be ready once, hence when we go to read it we will need to wrap the body stream that already exists. This means that from that point onwards, if anyone interacts with the body stream they will be using our copy (the Req/Res objects have a setter for the Body so this should be fine.
Next we need to attempt to read the stream to completion or till we have hit our trim limit (62k - this is a limit that we define so that we don't end up reading 100's mbs). With what ever data we read, we return as part of our payload, but we also need to keep a Memory Stream copy of it so that when someone else attempts to read the Body later we can given them that copy. Only slight trick is that if we only partially read the result previously, we will need to drain our Memory Stream copy first before switching back to the original Body stream.
Note, we also need to be content type/encoding aware as there isn't any point trimming binary content.