Receiving a request with a binary body #903
Replies: 1 comment 3 replies
-
Hey, @ellispritchard. Note that the If you wish to read the original response body for that captured request, you'll be doing something similar to response patching. Read original responseTo get the original response you need to perform the captured request first. You can do that using the ctx.fetch utility that's designed just for that. rest.put<ArrayBuffer>(/s3\.amazonaws\.com/, async (req, res, ctx) => {
// Perform an original request to the same endpoint.
// The returned data is an instance of the "Response".
const original = await ctx.fetch(req)
const body = await original.body
body.byteLength
}) Please bear in mind that this introduces an actual network request in your handler, which is not desired during testing. You can use this perfectly fine for development or debugging, though. |
Beta Was this translation helpful? Give feedback.
-
👋 Is there any way of retrieving the original request body as a binary (ArrayBuffer et al) using the
rest
handler?The TypeScript definitions seem to imply that this is supported in some way, but I can't work out how to actually get it to do this.
e.g.
res.body
seems to always be a string.EDIT: should be
req.body
!!Beta Was this translation helpful? Give feedback.
All reactions