This is meant for simple HTTP(S) requests.  The idea is that there is a procedure, http-request, that accepts a request dictionary and returns a reply dictionary.  In this context, dictionary is some unspecified key-value data structure.  Most of the dictionaries have symbol keys.

Redirects are performed automatically until a loop is seen or too many redirects: responses are chained using the request field of the response dictionary

Compression is automatically undone on received content, and must be specified on sent content

Request dictionary:

type: 'request
url: a string with the URL to request
verb: a symbol (upper cased on the wire) representing the HTTP verb
params: a dictionary mapping parameter names to parameter value strings (overrides the query part of the URL)
headers: dictionary of random request headers
content-type: media type of the content (string)
content-encoding: how the outgoing content is compressed (symbol)
cookies: a cookie jar (see below)
connection-timeout: time in jiffies for TCP connection
read-timeout: time in jiffies to send and receive the whole response
content: a string (encoded in UTF-8) or bytevector to send, or an input port to read chars or bytes from (possibly streaming)
file: a local file to send (mutually exclusive with content)
response-style: indicates how response content is delivered (string, bytevector, possibly binary or textual input port if provided by the implementation)


Response dictionary:

type: 'response
request: the request object
url: URL of a new resource
status: the status code (exact integer)
headers: random response headers
content: received content in one of 4 styles (see above)
cookies: a cookie jar (see below)
previous: another response dictionary of which this one is a retry


A cookie jar is a dictionary whose keys are lists (domain path id) and whose values are dictionaries with keys value, expires, max-age, secure, http-only, same-site.

We also will need procedures to do media type multipart/* encoding and decoding, as well as application/x-www-form-urlencoded.

Conditions: four types with predicates and a payload procedure

http-connection-error (payload is request): could not connect
http-timeout-error (payload is request): could not send and receive in time
http-request-error: (payload is response): status code is >= 300
http:redirect-error (payload is response): too many redirects or redirect loop


Comments?