PhpGt / Fetch

Asynchronous HTTP client with promises.

Home Page:https://www.php.gt/fetch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Body" trait.

g105b opened this issue · comments

These functions are available on the Response and Request. Can't see when they would be used to obtain the Request body content, but hey...

https://developer.mozilla.org/en-US/docs/Web/API/Body

Methods to implement:

  • arrayBuffer() The ArrayBuffer object is used to represent a generic, fixed-length raw binary data buffer. For our purposes, we will need to return a traversable object, but not sure how much use a fully-fledged ArrayBuffer will be to PHP.
  • blob() A Blob object represents a file-like object of immutable, raw data. While a Blob can be seen as a string (file_put_contents($blob)), it has some properties and methods that are useful to implement, such as size and slice()
  • formData() The FormData interface provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent as another fetch body.
  • json() Returns an object literal containing the response data (StdClass?)
  • text() Returns the string, formatted in the correct encoding, according to the Encoding header.