Next: , Previous: , Up: Top   [Contents][Index]


3 Requests

Each HTTP requests is represented using a ws-request object (see ws-request). The request object serves two purposes, one internal and one external. Internally, request objects are used to hold state while HTTP headers are parsed incrementally as the HTTP request text is received from the network. Externally, request objects are used to decide which handler to call, and are then passed as the only argument to the called handler.

In addition to fields used internally, each ws-request object holds the network process in the process and holds all HTTP headers and request GET or POST parameters in the headers alist. HTML Headers are keyed using uppercase keywords (e.g., :GET), and user supplied parameters are keyed using the string name of the parameter.

The process field may be used by handlers to send data to a client as in the following example.

(process-send-string (process request) "hello world")

The headers field may be used to access request information such as the requested path,

(cdr (assoc :GET (headers request)))

or named parameters as from a web form.

(cdr (assoc "message" (headers request)))