The trivial-http Reference Manual

This is the trivial-http Reference Manual, version 1.3.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Wed May 15 07:10:29 2024 GMT+0.

Table of Contents


1 Systems

The main system appears first, followed by any subsystem dependency.


1.1 trivial-http

Simple support for HTTP GET, POST and more.

Author

Brian Mastenbrook and Gary King

License

MIT

Version

1.3.0

Dependency

usocket (system).

Source

trivial-http.asd.

Child Component

dev (module).


2 Modules

Modules are listed depth-first from the system components tree.


2.1 trivial-http/dev

Source

trivial-http.asd.

Parent Component

trivial-http (system).

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 trivial-http/trivial-http.asd

Source

trivial-http.asd.

Parent Component

trivial-http (system).

ASDF Systems

trivial-http.

Packages

trivial-http-system.


3.1.2 trivial-http/dev/package.lisp

Source

trivial-http.asd.

Parent Component

dev (module).

Packages

trivial-http.


3.1.3 trivial-http/dev/variables.lisp

Dependency

package.lisp (file).

Source

trivial-http.asd.

Parent Component

dev (module).

Public Interface
Internals

3.1.4 trivial-http/dev/trivial-http.lisp

Dependency

variables.lisp (file).

Source

trivial-http.asd.

Parent Component

dev (module).

Public Interface
Internals

3.1.5 trivial-http/dev/base64.lisp

Dependency

variables.lisp (file).

Source

trivial-http.asd.

Parent Component

dev (module).

Internals

3.2 Static


3.2.1 trivial-http/dev/notes.text

Source

trivial-http.asd.

Parent Component

dev (module).


4 Packages

Packages are listed by definition order.


4.1 trivial-http

trivial-http is a simple networking library for doing HTTP POST
and GET over a socket interface. It establishes a package trivial-http, also called SHTTP, from which the following functions are exported: http-get, http-post, escape-url-query and http-head.

Source

package.lisp.

Nickname

shttp

Use List
  • common-lisp.
  • usocket.
Public Interface
Internals

4.2 trivial-http-system

Source

trivial-http.asd.

Use List
  • asdf/interface.
  • common-lisp.

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *http-debug*
Package

trivial-http.

Source

variables.lisp.

Special Variable: *user-agent*
Package

trivial-http.

Source

variables.lisp.


5.1.2 Ordinary functions

Function: escape-url-query (query)

Escapes a query string in accordance with the HTTP specification.

Package

trivial-http.

Source

trivial-http.lisp.

Function: header-pair (name headers)

Searches headers for name _without_ case sensitivity. Headers should be an alist mapping symbols to values; name a symbol. Returns the (name value) pair if name is found or nil if it is not.

Package

trivial-http.

Source

trivial-http.lisp.

Function: header-value (name headers)

Searchers headers for name _without_ case sensitivity. Headers should be an alist mapping symbols to values; name a symbol. Returns the value if name is found or nil if it is not.

Package

trivial-http.

Source

trivial-http.lisp.

Function: http-download (url destination &key signal-error?)

Resolves ‘url‘ using http-resolve and downloads the contents of the stream it to ‘destination‘. Destination is assumed to be a file. Returns (as multiple values) the number of elements downloaded (e.g., bytes) and the actual URL.

Package

trivial-http.

Source

trivial-http.lisp.

Function: http-get (url)

returns a list of three elements: a response code as integer, an association list of headers returned from the server, and a stream from which the response can be read.

Package

trivial-http.

Source

trivial-http.lisp.

Function: http-head (url)

Returns a list of two elements: a response code as an integer and an association list of headers returned from the server.

Package

trivial-http.

Source

trivial-http.lisp.

Function: http-post (url content-type content &key headers debug?)

given a URL, a MIME content type, and the content as a character stream, POST to the URL and return the list of three elements as described for [http-get][].

Package

trivial-http.

Source

trivial-http.lisp.

Function: http-resolve (url &key http-method signal-error? verbose?)

Similar to [http-get][], ‘http-resolve‘ returns a list of four elements: the HTTP response code, the headers, the stream
and the resolved URL. HTTP-response resolves 301 and 302 responses, and signals an error on responses greater
than 400. If there is not an error, then the caller is responsible for closing the HTTP stream.

Package

trivial-http.

Source

trivial-http.lisp.


5.1.3 Generic functions

Generic Reader: download-command (condition)
Package

trivial-http.

Methods
Reader Method: download-command ((condition download-error))
Source

trivial-http.lisp.

Target Slot

command.

Generic Reader: download-length-claimed (condition)
Package

trivial-http.

Methods
Reader Method: download-length-claimed ((condition mismatched-download-size-error))
Source

trivial-http.lisp.

Target Slot

length-claimed.

Generic Reader: download-length-downloaded (condition)
Package

trivial-http.

Methods
Reader Method: download-length-downloaded ((condition mismatched-download-size-error))
Source

trivial-http.lisp.

Target Slot

length-downloaded.

Generic Reader: download-response (condition)
Package

trivial-http.

Methods
Reader Method: download-response ((condition download-error))
Source

trivial-http.lisp.

Target Slot

response.

Generic Reader: download-url (condition)
Package

trivial-http.

Methods
Reader Method: download-url ((condition download-error))
Source

trivial-http.lisp.

Target Slot

url.

Generic Reader: stream-from (condition)
Package

trivial-http.

Methods
Reader Method: stream-from ((condition incompatible-stream-error))
Source

trivial-http.lisp.

Target Slot

from.

Generic Reader: stream-to (condition)
Package

trivial-http.

Methods
Reader Method: stream-to ((condition incompatible-stream-error))
Source

trivial-http.lisp.

Target Slot

to.


5.1.4 Conditions

Condition: download-error
Package

trivial-http.

Source

trivial-http.lisp.

Direct superclasses

trivial-http-error.

Direct subclasses

mismatched-download-size-error.

Direct methods
Direct slots
Slot: url
Initform

(quote "?")

Initargs

:url

Readers

download-url.

Writers

This slot is read-only.

Slot: command
Initform

(quote "?")

Initargs

:command

Readers

download-command.

Writers

This slot is read-only.

Slot: response
Initform

(quote "?")

Initargs

:response

Readers

download-response.

Writers

This slot is read-only.

Condition: incompatible-stream-error
Package

trivial-http.

Source

trivial-http.lisp.

Direct superclasses

trivial-http-error.

Direct methods
Direct slots
Slot: from
Initargs

:from

Readers

stream-from.

Writers

This slot is read-only.

Slot: to
Initargs

:to

Readers

stream-to.

Writers

This slot is read-only.

Condition: mismatched-download-size-error
Package

trivial-http.

Source

trivial-http.lisp.

Direct superclasses

download-error.

Direct methods
Direct slots
Slot: length-claimed
Initargs

:length-claimed

Readers

download-length-claimed.

Writers

This slot is read-only.

Slot: length-downloaded
Initargs

:length-downloaded

Readers

download-length-downloaded.

Writers

This slot is read-only.


5.2 Internals


5.2.1 Constants

Constant: +crlf+
Package

trivial-http.

Source

trivial-http.lisp.


5.2.2 Special variables

Special Variable: *encode-table*
Package

trivial-http.

Source

base64.lisp.

Special Variable: *proxy-password*
Package

trivial-http.

Source

variables.lisp.

Special Variable: *proxy-user*
Package

trivial-http.

Source

variables.lisp.

Special Variable: *stream-buffer-size*
Package

trivial-http.

Source

trivial-http.lisp.


5.2.3 Ordinary functions

Function: base64-encode (string)
Package

trivial-http.

Source

base64.lisp.

Function: copy-stream (from to)

Copy into TO from FROM until end of the input stream, in blocks of *stream-buffer-size*. The streams should have the same element type. Returns the total number of ’elements’ read and written.

Package

trivial-http.

Source

trivial-http.lisp.

Function: download-stream (stream destination &key expected-length)
Package

trivial-http.

Source

trivial-http.lisp.

Function: open-file-arguments ()
Package

trivial-http.

Source

trivial-http.lisp.

Function: response-read-code (stream)
Package

trivial-http.

Source

trivial-http.lisp.

Function: response-read-headers (stream)
Package

trivial-http.

Source

trivial-http.lisp.

Function: url-host (url)
Package

trivial-http.

Source

trivial-http.lisp.

Function: url-path (url)
Package

trivial-http.

Source

trivial-http.lisp.

Function: url-port (url)
Package

trivial-http.

Source

trivial-http.lisp.

Function: url-reserved-character-p (c)
Package

trivial-http.

Source

trivial-http.lisp.

Function: write-additional-headers (stream)
Package

trivial-http.

Source

trivial-http.lisp.

Function: write-crlf (stream)
Package

trivial-http.

Source

trivial-http.lisp.

Function: write-standard-headers (command url host stream)
Package

trivial-http.

Source

trivial-http.lisp.


5.2.4 Conditions

Condition: trivial-http-error
Package

trivial-http.

Source

trivial-http.lisp.

Direct superclasses

error.

Direct subclasses

Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   B   C   D   E   F   G   H   M   O   R   S   U   W  
Index Entry  Section

B
base64-encode: Private ordinary functions

C
copy-stream: Private ordinary functions

D
download-command: Public generic functions
download-command: Public generic functions
download-length-claimed: Public generic functions
download-length-claimed: Public generic functions
download-length-downloaded: Public generic functions
download-length-downloaded: Public generic functions
download-response: Public generic functions
download-response: Public generic functions
download-stream: Private ordinary functions
download-url: Public generic functions
download-url: Public generic functions

E
escape-url-query: Public ordinary functions

F
Function, base64-encode: Private ordinary functions
Function, copy-stream: Private ordinary functions
Function, download-stream: Private ordinary functions
Function, escape-url-query: Public ordinary functions
Function, header-pair: Public ordinary functions
Function, header-value: Public ordinary functions
Function, http-download: Public ordinary functions
Function, http-get: Public ordinary functions
Function, http-head: Public ordinary functions
Function, http-post: Public ordinary functions
Function, http-resolve: Public ordinary functions
Function, open-file-arguments: Private ordinary functions
Function, response-read-code: Private ordinary functions
Function, response-read-headers: Private ordinary functions
Function, url-host: Private ordinary functions
Function, url-path: Private ordinary functions
Function, url-port: Private ordinary functions
Function, url-reserved-character-p: Private ordinary functions
Function, write-additional-headers: Private ordinary functions
Function, write-crlf: Private ordinary functions
Function, write-standard-headers: Private ordinary functions

G
Generic Function, download-command: Public generic functions
Generic Function, download-length-claimed: Public generic functions
Generic Function, download-length-downloaded: Public generic functions
Generic Function, download-response: Public generic functions
Generic Function, download-url: Public generic functions
Generic Function, stream-from: Public generic functions
Generic Function, stream-to: Public generic functions

H
header-pair: Public ordinary functions
header-value: Public ordinary functions
http-download: Public ordinary functions
http-get: Public ordinary functions
http-head: Public ordinary functions
http-post: Public ordinary functions
http-resolve: Public ordinary functions

M
Method, download-command: Public generic functions
Method, download-length-claimed: Public generic functions
Method, download-length-downloaded: Public generic functions
Method, download-response: Public generic functions
Method, download-url: Public generic functions
Method, stream-from: Public generic functions
Method, stream-to: Public generic functions

O
open-file-arguments: Private ordinary functions

R
response-read-code: Private ordinary functions
response-read-headers: Private ordinary functions

S
stream-from: Public generic functions
stream-from: Public generic functions
stream-to: Public generic functions
stream-to: Public generic functions

U
url-host: Private ordinary functions
url-path: Private ordinary functions
url-port: Private ordinary functions
url-reserved-character-p: Private ordinary functions

W
write-additional-headers: Private ordinary functions
write-crlf: Private ordinary functions
write-standard-headers: Private ordinary functions


A.4 Data types

Jump to:   B   C   D   F   I   M   N   P   S   T   V  
Index Entry  Section

B
base64.lisp: The trivial-http/dev/base64․lisp file

C
Condition, download-error: Public conditions
Condition, incompatible-stream-error: Public conditions
Condition, mismatched-download-size-error: Public conditions
Condition, trivial-http-error: Private conditions

D
dev: The trivial-http/dev module
download-error: Public conditions

F
File, base64.lisp: The trivial-http/dev/base64․lisp file
File, notes.text: The trivial-http/dev/notes․text file
File, package.lisp: The trivial-http/dev/package․lisp file
File, trivial-http.asd: The trivial-http/trivial-http․asd file
File, trivial-http.lisp: The trivial-http/dev/trivial-http․lisp file
File, variables.lisp: The trivial-http/dev/variables․lisp file

I
incompatible-stream-error: Public conditions

M
mismatched-download-size-error: Public conditions
Module, dev: The trivial-http/dev module

N
notes.text: The trivial-http/dev/notes․text file

P
Package, trivial-http: The trivial-http package
Package, trivial-http-system: The trivial-http-system package
package.lisp: The trivial-http/dev/package․lisp file

S
System, trivial-http: The trivial-http system

T
trivial-http: The trivial-http system
trivial-http: The trivial-http package
trivial-http-error: Private conditions
trivial-http-system: The trivial-http-system package
trivial-http.asd: The trivial-http/trivial-http․asd file
trivial-http.lisp: The trivial-http/dev/trivial-http․lisp file

V
variables.lisp: The trivial-http/dev/variables․lisp file