You are looking at historical revision 2269 of this page. It may differ significantly from its current revision.
The http-server-form-posts egg extends the web server available in the http-server egg to include support for parsing of multipart/form-data form posts. It includes some data structures and utilties for representing and inspecting form posts.
http-server-form-posts is in the Public Domain and may be reproduced or copied without permission.
Canonical Usage With Spiffy
(use spiffy http-server-form-posts) (http:add-resource "/form-post" (lambda (req args) (let* ((form-fields (request->form-field-alist req)) (file-input (alist-ref "file" form-fields string=?)) (response (string-append "You uploaded a file called " (form-field:file-name file-input) " which has a content type of " (form-field:content-type file-input) ". The contents of this file are: " (form-field:body file-input)))) ; ... write the response ... )))
[procedure] (request->form-field-list req)
Returns a list of form-field records, one for each form field that has a part in the body of the HTTP request req, in the same order as the parts appear in the posted document.
[procedure] (request->form-field-alist req)
Same as request->form-field-list, but returns an association list which maps (string) names of form post parts to form-field records.
[procedure] (form-field-list->form-field-alist req)
Converts a form field list (as returned by request->form-field-list) into the same format as the return value of request->form-field-alist.
[procedure] (form-field? anything)
Returns a boolean indicating whether anything is of the form-field record type.
[procedure] (form-field:file-field? form-field)
Returns a boolean indicating whether form-field is a file field/file input (i.e. does its content-disposition header have a filename parameter?).
[procedure] (form-field:name form-field)
Returns the string name of form-field (i.e. the value of the name parameter of the corresponding content-disposition header).
[procedure] (form-field:body form-field)
Returns the string body of form-field (i.e. the body of its part in the form post).
[procedure] (form-field:content-type form-field)
Returns the string content type of form-field (i.e. the value of the content-type header for its part in the form post).
[procedure] (form-field:file-name form-field)
Returns the string name of the file whose content is the body of form-field. Will return #f if form-field is not a file field (i.e. if (form-field-file-field? form-field) does not evaluate to #t).