import { packRequest } from "https://deno.land/x/cav@0.0.24/serial.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 message
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 message is undefined
, the method is GET. If the message is null
,
the method is POST with no body. Any defined message (including null) results
in a POST request.
If the message 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 message 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 message 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 message
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.