import { packRequest } from "https://deno.land/x/cav@0.2.0-alpha.7/examples/chat/deps_dom.ts";
Serializes a new Request, which can then be deserialized using
unpack()
. Only GET and POST requests are supported; the method used
is automatically determined based on the presence of the body
init
option. Any headers specified on the init options will override the headers
determined during serialization. The serializable input types can be extended
with the serializers option.
If the body is undefined
, the method is GET. If the body is null
,
the method is POST with no body. Any defined body (including null) results
in a POST request.
If the body extends BodyInit, it'll be passed through to the Request constructor unmodified. It'll be deserialized according to the content-type set on the request headers, which can sometimes result in asymmetric deserialization.
If the body is a File or Blob, it'll also be sent with a "content-disposition: attachment" header. It'l be deserialized back into a regular Blob or File, along with the file name if there is one, regardless of the content-type.
If the body is any other type, it'll first be serialized as JSON using
serialize()
. The default serializers are extended to include Files and
Blobs; if a File or Blob exists on the serialized value, the request will be
sent as a specially formatted FormData instead of JSON. It'll be deserialized
back into the original body
with all the Files and Blobs back in the
right place. Referential equality for Files and Blobs will be preserved, so
that duplicate Blobs only have 1 copy uploaded.