(www server-utils parse-request) module provides procedures to
read the first line, the headers and the body, of an HTTP message on the
Keywords: s2s, style
Return a request object read from port. Use s2s (defaults to
string-titlecase) to normalize the header names. With
#:s2s string-downcase, for instance, you would see
(host . "example.com")in the
headersfield of the request object.
Keyword arg style is an object specifying the syntax of the initial (non-body) portion. By default, parse expects a normal HTTP 1.1 request message as per RFC 2616.
A request object has five fields.
- A symbol, such as
- A string. You can use
alist<-queryto break this down further.
- A pair of integers indicating the protocol version. For example,
(1 . 1)corresponds to HTTP 1.1.
- A list of pairs
), aka alist, where name is a symbol and value is a string. How name is normalized depends on which s2s was specified to
#for a procedure get-body. This should be called with one arg, flags, to retrieve the request body. See http, procedure
receive-response, for flags documentation.
Return the respective field of request object req.
Parse string upath and return three values representing its hierarchy, query and fragment components. If a component is missing, its value is
#f.(hqf<-upath "/aa/bb/cc?def=xyz&hmm#frag") ⇒ "/aa/bb/cc" ⇒ "def=xyz&hmm" ⇒ "frag" (hqf<-upath "/aa/bb/cc#fr?ag") ⇒ "/aa/bb/cc" ⇒ #f ⇒ "fr?ag"
Parse urlencoded query-string and return an alist. For each element
)of the alist, name is a string and value is either
#for a string.
NB: The following four procedures will NO LONGER BE AVAILABLE
after 2013-02-28. Better to use
Parse the first line of the HTTP message from input port and return a list of the method, URL path and HTTP version indicator, or
#fif the line ends prematurely or is otherwise malformed. A successful parse consumes the trailing ‘CRLF’ of the line as well. The method is a symbol with its constituent characters upcased, such as
GET; the other elements are strings. If the first line is missing the HTTP version,
parse-first-linereturns the default "HTTP/1.0".
Parse the headers of the HTTP message from input port and return a list of key/value pairs, or
#fif the message ends prematurely or is otherwise malformed. Both keys and values are strings. Values are trimmed of leading and trailing whitespace and may be empty. Values that span more than one line have their "continuation whitespace" reduced to a single space. A successful parse consumes the trailing ‘CRLF’ of the header block as well.
Sometimes you are interested in the body of the message but not the headers.
In this case, you can use
skip-headers to quickly position the port.
Scan without parsing the headers of the HTTP message from input port, and return the empty list, or
#fif the message ends prematurely. A successful scan consumes the trailing ‘CRLF’ of the header block as well.