# (lispkit http)

Library `(lispkit http)` provides an API for downloading data from and uploading data to endpoints specified by URLs using the HTTP family of protocols.

## HTTP sessions

HTTP session objects are used to coordinate a group of related data-transfer tasks. Within each session, typically a series of tasks are created, each of which represents a request for a specific URL. The tasks within a given HTTP session share a common session configuration, which defines connection behavior, like the maximum number of simultaneous connections to make to a single host, whether connections can use the cellular network, etc.

**http-session-type-tag** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-bdc0997c38ced7c944ea089918006133f1a4052f%2Fconst.png?alt=media" alt="" data-size="line">

Symbol representing the `http-session` type. The `type-for` procedure of library `(lispkit type)` returns this symbol for all HTTP session objects.

**current-http-session** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-88f16e644c1b8e131aef4cc56ada3c07becf0ab2%2Fparam.png?alt=media" alt="" data-size="line">

This parameter object represents the current default HTTP session. By default, this is set to a shared multi-purpose session object. Procedures requiring an HTTP session typically make the HTTP session argument optional. If it is not provided, the result of `(current-http-session)` is used instead. The value of `current-http-session` can be overridden with `parameterize`.

**(http-session?&#x20;*****obj*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns `#t` if *obj* is a HTTP session object; `#f` otherwise.

**(make-http-session)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(make-http-session&#x20;*****proto*****)**\
\&#xNAN;**(make-http-session&#x20;*****proto timeout*****)**\
\&#xNAN;**(make-http-session&#x20;*****proto timeout cookies?*****)**\
\&#xNAN;**(make-http-session&#x20;*****proto timeout cookies? cache*****)**\
\&#xNAN;**(make-http-session&#x20;*****proto timeout cookies? cache maxcon*****)**\
\&#xNAN;**(make-http-session&#x20;*****proto timeout cookies? cache maxcon pipe?*****)**\
\&#xNAN;**(make-http-session&#x20;*****proto timeout cookies? cache maxcon pipe? cell?*****)**

Returns a new HTTP session object. The configuration is copied from the prototype HTTP object *proto*. The arguments following *proto* override individual settings of *proto*. If one of those arguments is set to `()`, then it is ignored.

If *proto* is `#f` (or not provided at all), system-specific defaults are used. If *proto* is `#t`, an *ephemeral* session default is used which is not writing caches, cookies, or credentials to disk. Otherwise, it is assumed *proto* is an HTTP session object whose configuration will be used for the newly created HTTP session object.

*timeout* defines the time in seconds to wait for (additional) data. The default is 60. *cookies?* is a boolean argument determining whether requests should automatically provide cookies from the shared cookie store. The default is `#t`. If set to `#f`, then cookie headers need to be provided manually.

*cache* defines a cache policy. The following policies, specified as symbols, are supported:

* `use-protocol-cache-policy`: Use the caching logic defined in the protocol implementation (default).
* `reload-ignoring-local-cache`: The URL load should be loaded only from the originating source.
* `reload-ignoring-local-remote-cache`: Ignore local cache data, and instruct proxies and other intermediates to disregard their caches so far as the protocol allows.
* `return-cache-data-else-load`: Use existing cache data, regardless or age or expiration date, loading from originating source only if there is no cached data.
* `return-cache-data-dont-load`: Use existing cache data, regardless or age or expiration date, and fail if no cached data is available.
* `reload-revalidating-cache`: Use cache data if the origin source can validate it; otherwise, load from the origin.

Argument *maxcon* specifies the maximum number of simultaneous connections made to each host by requests initiated by this session. The default value is 6. *pipe?* is a boolean argument determining whether HTTP pipelining should be used. *cell?* is a boolean argument specifying whether connections should be made over a cellular network.

**(http-session-copy)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-copy&#x20;*****session*****)**

Returns a copy of *session*. If argument *session* is not provided, a copy of the current value of parameter object `current-http-session` is returned.

**(http-session-timeout)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-timeout&#x20;*****session*****)**

Returns the connection timeout for *session*. This is the time in seconds to wait for (additional) data. If argument *session* is not provided, the current value of parameter object `current-http-session` is used as a default.

**(http-session-send-cookies?)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-send-cookies?&#x20;*****session*****)**

Returns a boolean value determining whether requests sent via *session* automatically provide cookies from the shared cookie store. If argument *session* is not provided, the current value of parameter object `current-http-session` is used as a default.

**(http-session-cache-policy)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-cache-policy&#x20;*****session*****)**

Returns the cache policy used by *session*. If argument *session* is not provided, the current value of parameter object `current-http-session` is used as a default.

The following cache policies are supported: `use-protocol-cache-policy`, `reload-ignoring-local-cache`, `reload-ignoring-local-remote-cache`, `return-cache-data-else-load`, `return-cache-data-dont-load`, `reload-revalidating-cache`. Details are provided in the description of procedure `make-http-session`.

**(http-session-max-connections)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-max-connections&#x20;*****session*****)**

Returns the maximum number of simultaneous connections made to each host by requests initiated by *session*. If *session* is not provided, the current value of parameter object `current-http-session` is used as a default.

**(http-session-use-pipelining?)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-use-pipelining?&#x20;*****session*****)**

Returns a boolean value determining whether HTTP pipelining should be used by *session*. If *session* is not provided, the current value of parameter object `current-http-session` is used.

**(http-session-allow-cellular?)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-allow-cellular?&#x20;*****session*****)**

Returns a boolean value determining whether connections should be made over a cellular network by *session*. If *session* is not provided, the current value of parameter object `current-http-session` is used.

**(http-session-tasks)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-tasks&#x20;*****session*****)**

Returns a future which will eventually hold the number of currently ongoing tasks initiated via *session*. If *session* is not provided, the current value of parameter object `current-http-session` is used.

**(http-session-flush!)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-flush!&#x20;*****session*****)**

Flushes cookies and credentials to disk, clears transient caches, and ensures that future requests sent via *session* occur on a new TCP connection. Returns a future which will eventually be set to `#t` once flush has completed. If *session* is not provided, the current value of parameter object `current-http-session` is used.

**(http-session-reset!)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-reset!&#x20;*****session*****)**

Empties all cookies, caches and credential stores, removes disk files, flushes in-progress downloads to disk, and ensures that future requests initiated via *session* occur on a new socket. Returns a future which will eventually be set to `#t` once reset has completed. If *session* is not provided, the current value of parameter object `current-http-session` is used.

**(http-session-finish!)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-finish!&#x20;*****session*****)**

This procedure invalidates the session, allowing any outstanding tasks to finish. It returns immediately without waiting for tasks to finish. Once a session is invalidated, new tasks cannot be created in the session, but existing tasks continue until completion. After invalidation, session objects cannot be reused. To cancel all outstanding tasks immediately, call procedure `http-session-cancel!` instead. If *session* is not provided, the current value of parameter object `current-http-session` is used.

**(http-session-cancel!)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-cancel!&#x20;*****session*****)**

Cancels all outstanding tasks and then invalidates the session. Once invalidated, outstanding tasks will not complete (e.g. by initializing a future) and the session object cannot be reused.\
To allow outstanding tasks to run until completion, call `http-session-finish!` instead. If *session* is not provided, the current value of parameter object `current-http-session` is used.

**(http-session-send&#x20;*****request*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-session-send&#x20;*****request session*****)**

Creates a task that retrieves the contents of a URL via the specified HTTP request object *request*, and eventually stores a HTTP result object in the future returned by `http-session-send`. If *session* is not provided, the current value of parameter object `current-http-session` is used.

## HTTP requests

**http-request-type-tag** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-bdc0997c38ced7c944ea089918006133f1a4052f%2Fconst.png?alt=media" alt="" data-size="line">

Symbol representing the `http-request` type. The `type-for` procedure of library `(lispkit type)` returns this symbol for all HTTP request objects.

**(http-request?&#x20;*****obj*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns `#t` if *obj* is a HTTP request object; `#f` otherwise.

**(make-http-request&#x20;*****url meth*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(make-http-request&#x20;*****url meth headers*****)**\
\&#xNAN;**(make-http-request&#x20;*****url meth headers timeout*****)**\
\&#xNAN;**(make-http-request&#x20;*****url meth headers timeout cookies?*****)**\
\&#xNAN;**(make-http-request&#x20;*****url meth headers timeout cookies? cache*****)**\
\&#xNAN;**(make-http-request&#x20;*****url meth headers timeout cookies? cache pipe?*****)**\
\&#xNAN;**(make-http-request&#x20;*****url meth headers timeout cookies? cache pipe? cell?*****)**

Returns a new HTTP request for *url* using the HTTP method *meth*. Supported are the methods `"GET"`, `"HEAD"`, `"POST"`, `"PUT"`, `"DELETE"`, `"CONNECT"`, `"OPTIONS"`, `"TRACE"`, and `"PATCH"`. *headers* is an association list mapping HTTP header names (strings) into header values (strings). The remaining arguments override settings of the session when the request is sent. `()` denotes that the setting of the session should be used.

*timeout* defines the time in seconds to wait for (additional) data. *cookies?* is a boolean argument determining whether requests should automatically provide cookies from the shared cookie store. *cache* defines a cache policy (see `make-http-request`). *pipe?* is a boolean argument determining whether HTTP pipelining should be used. *cell?* is a boolean argument specifying whether connections should be made over a cellular network.

**(http-request-copy&#x20;*****req*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-request-copy&#x20;*****req headers*****)**\
\&#xNAN;**(http-request-copy&#x20;*****req headers timeout*****)**\
\&#xNAN;**(http-request-copy&#x20;*****req headers timeout cookies?*****)**\
\&#xNAN;**(http-request-copy&#x20;*****req headers timeout cookies? cache*****)**\
\&#xNAN;**(http-request-copy&#x20;*****req headers timeout cookies? cache pipe?*****)**\
\&#xNAN;**(http-request-copy&#x20;*****req headers timeout cookies? cache pipe? cell?*****)**

Returns a copy of HTTP request *req*. The arguments following *req* override existing settings of *req*. If one of those arguments is set to `()` (or `#f` for non-boolean parameters), then it is ignored.

*headers* is an association list mapping HTTP header names (strings) into header values (strings). *timeout* defines the time in seconds to wait for (additional) data. *cookies?* is a boolean argument determining whether requests should automatically provide cookies from the shared cookie store. *cache* defines a cache policy (see `make-http-request`). *pipe?* is a boolean argument determining whether HTTP pipelining should be used. *cell?* is a boolean argument specifying whether connections should be made over a cellular network.

**(http-request-url&#x20;*****req*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the ULR of HTTP request *req* as a string.

**(http-request-method&#x20;*****req*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the HTTP method of HTTP request *req* as a string.

**(http-request-headers&#x20;*****req*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the headers of HTTP request *req* as an association list mapping HTTP header names (strings) into header values (strings).

**(http-request-header&#x20;*****req key*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the value for the HTTP header *key* from HTTP request *req* as a string. If header *key* does not exist, then `#f` is returned.

**(http-request-header-set!&#x20;*****req key value*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Sets the value for the HTTP header *key* (string) in HTTP request *req* to *value*. *value* can either be a fixnum, flonum, boolean, symbol, or string. It is automatically converted into a string and stored as the new header value for *key*. If header *key* existed before, it is overridden with a new value via `http-request-header-set!`.

**(http-request-header-remove!&#x20;*****req key*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Removes HTTP header *key* (string) from HTTP request *req*. If *key* does not exist, then *req* does not change.

**(http-request-content&#x20;*****req*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the body of HTTP request *req* as a bytevector. If no body has been defined for *req*, the `#f` is returned.

**(http-request-content-set!&#x20;*****req bvec*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-request-content-set!&#x20;*****req bvec start*****)**\
\&#xNAN;**(http-request-content-set!&#x20;*****req bvec start end*****)**

Assigns bytevector *bvec* between *start* and *end* as the body to HTTP request *req*. If *end* is not provided, it is assumed to be the length of *bytevector*. If *start* is not provided, it is assumed to be 0.

**(http-request-timeout&#x20;*****req*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the timeout in seconds associated with HTTP request *req*.

**(http-request-timeout-set!&#x20;*****req timeout*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Sets the timeout in seconds to *timeout* for HTTP request *req*.

**(http-request-send-cookies&#x20;*****req*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns `#t` if HTTP request *req* has been configured to automatically provide cookies from the shared cookie store. If the request has been configured to not provide cookies, then `#f` is returned. Without an explicit configuration of this setting, `()` is returned.

**(http-request-cache-policy&#x20;*****req*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the caching policy associated with HTTP request *req*, if one was set explicitly. Otherwise, `()` is returned. The following policies, specified as symbols, are supported: `use-protocol-cache-policy`, `reload-ignoring-local-cache`, `reload-ignoring-local-remote-cache`, `return-cache-data-else-load`, `return-cache-data-dont-load`, and `reload-revalidating-cache`.

**(http-request-use-pipelining&#x20;*****req*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns `#t` if HTTP request *req* has been configured to use HTTP pipelining. If the request has been configured to not use pipelining, then `#f` is returned. Without an explicit configuration of this setting, `()` is returned.

**(http-request-allow-cellular&#x20;*****req*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns `#t` if HTTP request *req* has been configured to allow connections over cellular networks. If the request has been configured to not allow cellular connections, then `#f` is returned. Without an explicit configuration of this setting, `()` is returned.

## HTTP responses

**http-response-type-tag** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-bdc0997c38ced7c944ea089918006133f1a4052f%2Fconst.png?alt=media" alt="" data-size="line">

Symbol representing the `http-response` type. The `type-for` procedure of library `(lispkit type)` returns this symbol for all HTTP response objects.

**(http-response?&#x20;*****obj*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns `#t` if *obj* is a HTTP response object; `#f` otherwise.

**(http-response-content&#x20;*****resp*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the body of the HTTP response *resp* as a bytevector.

**(http-response-status-code&#x20;*****resp*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the status code of the HTTP response *resp* as a fixnum.

**(http-response-mime-type&#x20;*****resp*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the MIME type describing the type of content provided by HTTP response *resp* as a string. If no specific MIME type was included in *resp*, then `#f` is returned.

**(http-response-encoding&#x20;*****resp*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the text encoding name provided by HTTP response *resp* as a string. If no specific text encoding name was included in *resp*, then `#f` is returned.

**(http-response-url&#x20;*****resp*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the URL for the HTTP response *resp* as a string. If the URL is unknown, then `#f` is returned.

**(http-response-headers&#x20;*****resp*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-response-headers&#x20;*****resp str?*****)**

Returns the headers of HTTP response *resp* as an association list mapping HTTP header names (strings) into header values, which are either fixnums, flonums, booleans, or strings. Header values can be forced to be represented as a string if *str?* is set to `#t` (default is `#f`).

**(http-response-header&#x20;*****resp key*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(http-response-header&#x20;*****resp key str?*****)**

Returns the value for the HTTP header *key* from HTTP request *req* either as a fixnum, flonum, boolean or string. If header *key* does not exist, then `#f` is returned. The result can be forced to be a string if *str?* is set to `#t` (default is `#f`).

## Miscellaneous

**(http-status-code->string&#x20;*****sc*****)**     <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns a string representation for numeric HTTP status code *sc*.
