The http-parse Reference Manual

This is the http-parse Reference Manual, version 0.1.10, generated automatically by Declt version 4.0 beta 2 "William Riker" on Thu Feb 15 06:14:30 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

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


2.1 http-parse

A library for parsing HTTP requests/responses (synchronous or asynchronous).

Author

Andrew Danger Lyon <>

License

MIT

Version

0.1.10

Dependencies
  • babel (system).
  • cl-ppcre (system).
Source

http-parse.asd.

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 http-parse/http-parse.asd

Source

http-parse.asd.

Parent Component

http-parse (system).

ASDF Systems

http-parse.


3.1.2 http-parse/package.lisp

Source

http-parse.asd.

Parent Component

http-parse (system).

Packages

http-parse.


3.1.3 http-parse/util.lisp

Dependency

package.lisp (file).

Source

http-parse.asd.

Parent Component

http-parse (system).

Internals

3.1.4 http-parse/parse.lisp

Dependency

util.lisp (file).

Source

http-parse.asd.

Parent Component

http-parse (system).

Public Interface
Internals

3.1.5 http-parse/multipart-parse.lisp

Dependency

util.lisp (file).

Source

http-parse.asd.

Parent Component

http-parse (system).

Public Interface

make-multipart-parser (function).

Internals

4 Packages

Packages are listed by definition order.


4.1 http-parse

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

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


5.1 Public Interface


5.1.1 Ordinary functions

Function: make-multipart-parser (headers callback)

Make a multipart parser. Returns a closure that accepts a byte array of data from an HTTP body. Can be sent in in chunks. Callback will be called whenever a complete data chunk is sent in (called for each part in the data chunk) or as a continuation of a chunk that complete headers were sent in for but didn’t finish sending in its body.

Package

http-parse.

Source

multipart-parse.lisp.

Function: make-parser (http &key header-callback body-callback multipart-callback finish-callback store-body)

Return a closure that parses an HTTP request/response by calling it with
the bytes received as its only argument. The closure returns three values: the http object passed in, a boolean representing whether the headers have been fully parsed, and a boolean representing whether the request/response is finished (blank body, all body bytes accounted for, or 0-length chunk received).

During the parsing, the closure will call (if specified) the ‘header-callback‘ with all the headers as a plist once they are fully parsed, and the ‘body-callback‘ with the body once either it finishes parsing (if we have Content-Length) or once for each set of completed chunks sent, which allows streaming the body as it comes in. If a multipart callback is given, it will be called at least once for each form field present in the multipart form data.

The ‘:finish-callback‘ will be called when the HTTP payload is fully processed.

The :store-body keyword indicates to the parser that we wish to keep the body (in its entirety) in the http object passed in (accessible via the http-body accessor). Otherwise, the body will be discarded as it’s parsed (but remember, will still be sent to the body-callback as it comes in).
Parsing can be forced to completion by passing :EOF into the data arg. It is recommended to do this if the client/server closes the connection before you do.

Package

http-parse.

Source

parse.lisp.


5.1.2 Generic functions

Generic Reader: http-body (object)
Package

http-parse.

Methods
Reader Method: http-body ((http http))

automatically generated reader method

Source

parse.lisp.

Target Slot

body.

Generic Writer: (setf http-body) (object)
Package

http-parse.

Methods
Writer Method: (setf http-body) ((http http))

automatically generated writer method

Source

parse.lisp.

Target Slot

body.

Generic Reader: http-force-stream (object)
Package

http-parse.

Methods
Reader Method: http-force-stream ((http http))

automatically generated reader method

Source

parse.lisp.

Target Slot

force-stream.

Generic Writer: (setf http-force-stream) (object)
Package

http-parse.

Methods
Writer Method: (setf http-force-stream) ((http http))

automatically generated writer method

Source

parse.lisp.

Target Slot

force-stream.

Generic Reader: http-headers (object)
Package

http-parse.

Methods
Reader Method: http-headers ((http http))

automatically generated reader method

Source

parse.lisp.

Target Slot

headers.

Generic Writer: (setf http-headers) (object)
Package

http-parse.

Methods
Writer Method: (setf http-headers) ((http http))

automatically generated writer method

Source

parse.lisp.

Target Slot

headers.

Generic Reader: http-method (object)
Package

http-parse.

Methods
Reader Method: http-method ((http-request http-request))

automatically generated reader method

Source

parse.lisp.

Target Slot

method.

Generic Writer: (setf http-method) (object)
Package

http-parse.

Methods
Writer Method: (setf http-method) ((http-request http-request))

automatically generated writer method

Source

parse.lisp.

Target Slot

method.

Generic Reader: http-resource (object)
Package

http-parse.

Methods
Reader Method: http-resource ((http-request http-request))

automatically generated reader method

Source

parse.lisp.

Target Slot

resource.

Generic Writer: (setf http-resource) (object)
Package

http-parse.

Methods
Writer Method: (setf http-resource) ((http-request http-request))

automatically generated writer method

Source

parse.lisp.

Target Slot

resource.

Generic Reader: http-status (object)
Package

http-parse.

Methods
Reader Method: http-status ((http-response http-response))

automatically generated reader method

Source

parse.lisp.

Target Slot

status.

Generic Writer: (setf http-status) (object)
Package

http-parse.

Methods
Writer Method: (setf http-status) ((http-response http-response))

automatically generated writer method

Source

parse.lisp.

Target Slot

status.

Generic Reader: http-status-text (object)
Package

http-parse.

Methods
Reader Method: http-status-text ((http-response http-response))

automatically generated reader method

Source

parse.lisp.

Target Slot

status-text.

Generic Writer: (setf http-status-text) (object)
Package

http-parse.

Methods
Writer Method: (setf http-status-text) ((http-response http-response))

automatically generated writer method

Source

parse.lisp.

Target Slot

status-text.

Generic Reader: http-store-body (object)
Package

http-parse.

Methods
Reader Method: http-store-body ((http http))

automatically generated reader method

Source

parse.lisp.

Target Slot

store-body.

Generic Writer: (setf http-store-body) (object)
Package

http-parse.

Methods
Writer Method: (setf http-store-body) ((http http))

automatically generated writer method

Source

parse.lisp.

Target Slot

store-body.

Generic Reader: http-version (object)
Package

http-parse.

Methods
Reader Method: http-version ((http http))

automatically generated reader method

Source

parse.lisp.

Target Slot

version.

Generic Writer: (setf http-version) (object)
Package

http-parse.

Methods
Writer Method: (setf http-version) ((http http))

automatically generated writer method

Source

parse.lisp.

Target Slot

version.


5.1.3 Standalone methods

Method: print-object ((http http-request) s)
Source

parse.lisp.

Method: print-object ((http http) s)
Source

parse.lisp.

Method: print-object ((http http-response) s)
Source

parse.lisp.


5.1.4 Classes

Class: http

Base HTTP class, holds data common to both requests and responses.

Package

http-parse.

Source

parse.lisp.

Direct subclasses
Direct methods
Direct slots
Slot: version
Initform

1

Initargs

:version

Readers

http-version.

Writers

(setf http-version).

Slot: headers
Initargs

:headers

Readers

http-headers.

Writers

(setf http-headers).

Slot: store-body
Initargs

:store-body

Readers

http-store-body.

Writers

(setf http-store-body).

Slot: force-stream
Initargs

:force-stream

Readers

http-force-stream.

Writers

(setf http-force-stream).

Slot: body
Initform

(make-array 0 :element-type (quote (unsigned-byte 8)))

Initargs

:body

Readers

http-body.

Writers

(setf http-body).

Class: http-request

HTTP request class, extends ‘http‘ and holds all request-specific data.

Package

http-parse.

Source

parse.lisp.

Direct superclasses

http.

Direct methods
Direct slots
Slot: method
Package

common-lisp.

Initargs

:method

Readers

http-method.

Writers

(setf http-method).

Slot: resource
Initform

"/"

Initargs

:resource

Readers

http-resource.

Writers

(setf http-resource).

Class: http-response

HTTP response class, extends ‘http‘ and holds all response-specific data.

Package

http-parse.

Source

parse.lisp.

Direct superclasses

http.

Direct methods
Direct slots
Slot: status
Initform

0

Initargs

:status

Readers

http-status.

Writers

(setf http-status).

Slot: status-text
Initform

""

Initargs

:status-text

Readers

http-status-text.

Writers

(setf http-status-text).


5.2 Internals


5.2.1 Special variables

Special Variable: *scanner-content-disposition-kv-pairs*

Grabs the key/value pairs from a Content-Disposition header.

Package

http-parse.

Source

multipart-parse.lisp.

Special Variable: *scanner-find-first-header*

Create a scanner to find the first header in a string.

Package

http-parse.

Source

parse.lisp.

Special Variable: *scanner-header-parse-kv*

Create a regex scanner for splitting header kv pairs up.

Package

http-parse.

Source

parse.lisp.

Special Variable: *scanner-header-parse-line*

Create a regex scanner for splitting header lines up.

Package

http-parse.

Source

parse.lisp.

Special Variable: *scanner-numeric*

Create a regex scanner that detects if a string can be converted to a numver.

Package

http-parse.

Source

parse.lisp.


5.2.2 Ordinary functions

Function: append-array (arr1 arr2)

Create an array, made up of arr1 followed by arr2.

Package

http-parse.

Source

util.lisp.

Function: convert-headers-plist (header-str)

Pull out headers in a plist from a string.

Package

http-parse.

Source

parse.lisp.

Function: find-non-whitespace-pos (seq &key start)

Find the position of the first non-whitespace character in a sequence.

Package

http-parse.

Source

util.lisp.

Function: get-complete-chunks (data)

Given a chunk (octet vector) of HTTP data, return only the data from the *complete* chunks in the data and return the position in the byte vector of the start of the next chunk, and lastly return whether the last chunk (the 0-byte chunk) has been parsed (ie, HTTP body complete).

Package

http-parse.

Source

parse.lisp.

Function: get-header-block (bytes &key get-previous-line)

Given the bytes of an HTTP request/response, pull out only the headers and optionally the line above the start of the headers. Returns the headers as a string.

Package

http-parse.

Source

parse.lisp.

Function: get-header-kv-pairs (content-disposition-header-str)

Given a content-disposition header value, pull out the key/value pairs in it.

Package

http-parse.

Source

multipart-parse.lisp.


5.2.3 Generic functions

Generic Function: parse-headers (http bytes)

Given a slew of HTTP bytes, parse the headers out of them along with any other useful information lurking in there (status code, resource, etc). Returns the HTTP object passed in.

Package

http-parse.

Source

parse.lisp.

Methods
Method: parse-headers ((http http-response) (bytes vector))
Method: parse-headers ((http http-request) (bytes vector))

Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
A   C   F   G   H   M   P  
Index Entry  Section

(
(setf http-body): Public generic functions
(setf http-body): Public generic functions
(setf http-force-stream): Public generic functions
(setf http-force-stream): Public generic functions
(setf http-headers): Public generic functions
(setf http-headers): Public generic functions
(setf http-method): Public generic functions
(setf http-method): Public generic functions
(setf http-resource): Public generic functions
(setf http-resource): Public generic functions
(setf http-status): Public generic functions
(setf http-status): Public generic functions
(setf http-status-text): Public generic functions
(setf http-status-text): Public generic functions
(setf http-store-body): Public generic functions
(setf http-store-body): Public generic functions
(setf http-version): Public generic functions
(setf http-version): Public generic functions

A
append-array: Private ordinary functions

C
convert-headers-plist: Private ordinary functions

F
find-non-whitespace-pos: Private ordinary functions
Function, append-array: Private ordinary functions
Function, convert-headers-plist: Private ordinary functions
Function, find-non-whitespace-pos: Private ordinary functions
Function, get-complete-chunks: Private ordinary functions
Function, get-header-block: Private ordinary functions
Function, get-header-kv-pairs: Private ordinary functions
Function, make-multipart-parser: Public ordinary functions
Function, make-parser: Public ordinary functions

G
Generic Function, (setf http-body): Public generic functions
Generic Function, (setf http-force-stream): Public generic functions
Generic Function, (setf http-headers): Public generic functions
Generic Function, (setf http-method): Public generic functions
Generic Function, (setf http-resource): Public generic functions
Generic Function, (setf http-status): Public generic functions
Generic Function, (setf http-status-text): Public generic functions
Generic Function, (setf http-store-body): Public generic functions
Generic Function, (setf http-version): Public generic functions
Generic Function, http-body: Public generic functions
Generic Function, http-force-stream: Public generic functions
Generic Function, http-headers: Public generic functions
Generic Function, http-method: Public generic functions
Generic Function, http-resource: Public generic functions
Generic Function, http-status: Public generic functions
Generic Function, http-status-text: Public generic functions
Generic Function, http-store-body: Public generic functions
Generic Function, http-version: Public generic functions
Generic Function, parse-headers: Private generic functions
get-complete-chunks: Private ordinary functions
get-header-block: Private ordinary functions
get-header-kv-pairs: Private ordinary functions

H
http-body: Public generic functions
http-body: Public generic functions
http-force-stream: Public generic functions
http-force-stream: Public generic functions
http-headers: Public generic functions
http-headers: Public generic functions
http-method: Public generic functions
http-method: Public generic functions
http-resource: Public generic functions
http-resource: Public generic functions
http-status: Public generic functions
http-status: Public generic functions
http-status-text: Public generic functions
http-status-text: Public generic functions
http-store-body: Public generic functions
http-store-body: Public generic functions
http-version: Public generic functions
http-version: Public generic functions

M
make-multipart-parser: Public ordinary functions
make-parser: Public ordinary functions
Method, (setf http-body): Public generic functions
Method, (setf http-force-stream): Public generic functions
Method, (setf http-headers): Public generic functions
Method, (setf http-method): Public generic functions
Method, (setf http-resource): Public generic functions
Method, (setf http-status): Public generic functions
Method, (setf http-status-text): Public generic functions
Method, (setf http-store-body): Public generic functions
Method, (setf http-version): Public generic functions
Method, http-body: Public generic functions
Method, http-force-stream: Public generic functions
Method, http-headers: Public generic functions
Method, http-method: Public generic functions
Method, http-resource: Public generic functions
Method, http-status: Public generic functions
Method, http-status-text: Public generic functions
Method, http-store-body: Public generic functions
Method, http-version: Public generic functions
Method, parse-headers: Private generic functions
Method, parse-headers: Private generic functions
Method, print-object: Public standalone methods
Method, print-object: Public standalone methods
Method, print-object: Public standalone methods

P
parse-headers: Private generic functions
parse-headers: Private generic functions
parse-headers: Private generic functions
print-object: Public standalone methods
print-object: Public standalone methods
print-object: Public standalone methods