ProjectEvergreen / greenwood

Greenwood is your full-stack workbench for the web, focused on supporting modern web standards and development to help you create your next project.
https://www.greenwoodjs.io
MIT License
95 stars 9 forks source link

support additional `Request.body` formats #1147

Open thescientist13 opened 10 months ago

thescientist13 commented 10 months ago

Type of Change

Feature

Summary

Coming out of #1132 , while we were able to support all the options for a Response constructor options, [we were not able to do so for Request](), but also, for Request.body specifically, a number of options were not validated. We definitely have support for

  1. .text()
  2. .json() (application/json)
  3. .formData() (only supports application/x-www-url-encoded at this time)

So this is a tracking issue to make sure we revist these and test / support them where applicable

Details

Addition options we would like to support both from front end and back end:

  1. .formData() (multipart/form-data / file uploads)
  2. URLSearchParams
  3. ReadableStream
  4. Blob / blob()
  5. ArrayBuffer / arrayBuffer()
  6. TypedArray
  7. DataView

I think most of this may be limited by what is actually possible over HTTP in the first place.


It should be noted that part of the struggle is due to Koa not being able to provide a fully formed Request object by default, as well as for development, having to use Workers (which can only support string data structures) to do cache busting like for API routes.

So I think this could / should be all done comprehensively.