diff options
author | James LewisMoss <dres@debian.org> | 2001-07-27 23:45:29 -0400 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2017-02-20 00:05:29 -0800 |
commit | f559c149c83da84d0b1c285f0298c84aec564af9 (patch) | |
tree | f1c91bcb9bb5e6dad87b643127c3f878d80d89ee /http-cgi.txi | |
parent | c394920caedf3dac1981bb6b10eeb47fd6e4bb21 (diff) | |
parent | 87b82b5822ca54228cfa6df29be3ad9d4bc47d16 (diff) | |
download | slib-f559c149c83da84d0b1c285f0298c84aec564af9.tar.gz slib-f559c149c83da84d0b1c285f0298c84aec564af9.zip |
Import Debian changes 2d2-1debian/2d2-1
slib (2d2-1) unstable; urgency=low
* New upstream version
* Revert back to free. Is now so.
slib (2d1-1) unstable; urgency=low
* New upstream version.
* Move to non-free. FSF pointed out license doesn't allow modified
versions to be distributed.
* Get a complete list of copyrights that apply to the source into
copyright file.
* Remove setup for guile 1.3.
* Remove postrm. Just calling install-info (lintian) Move install-info
call to prerm since doc-base doesn't do install-info.
slib (2c9-3) unstable; urgency=low
* Change info location to section "The Algorithmic Language Scheme" to
match up with where guile puts it's files.
* Postinst is running slibconfig now. (Closes: #75891)
slib (2c9-2) unstable; urgency=low
* Stop installing slibconfig (for guile).
* In postinst if /usr/sbin/slibconnfig exists call it (Close: #75843
#75891).
slib (2c9-1) unstable; urgency=low
* New upstream (Closes: #74760)
* replace string-index with strsrch:string-index in http-cgi.scm.
* Add doc-base support (Closes: #31163)
Diffstat (limited to 'http-cgi.txi')
-rw-r--r-- | http-cgi.txi | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/http-cgi.txi b/http-cgi.txi new file mode 100644 index 0000000..67be216 --- /dev/null +++ b/http-cgi.txi @@ -0,0 +1,112 @@ +@code{(require 'http)} or @code{(require 'cgi)} +@ftindex http +@ftindex cgi + + +@defun http:header alist +Returns a string containing lines for each element of @var{alist}; the +@code{car} of which is followed by @samp{: }, then the @code{cdr}. +@end defun + +@defun http:content alist body @dots{} +Returns the concatenation of strings @var{body} with the +@code{(http:header @var{alist})} and the @samp{Content-Length} prepended. +@end defun + +@defvar *http:byline* +String appearing at the bottom of error pages. +@end defvar + +@defun http:error-page status-code reason-phrase html-string @dots{} +@var{status-code} and @var{reason-phrase} should be an integer and string as specified in +@cite{RFC 2068}. The returned page (string) will show the @var{status-code} and @var{reason-phrase} +and any additional @var{html-strings} @dots{}; with @var{*http:byline*} or SLIB's +default at the bottom. +@end defun + +@defun http:forwarding-page title delay uri html-string @dots{} +The string or symbol @var{title} is the page title. @var{delay} is a non-negative +integer. The @var{html-strings} @dots{} are typically used to explain to the user why +this page is being forwarded. + +@code{http:forwarding-page} returns an HTML string for a page which automatically forwards to +@var{uri} after @var{delay} seconds. The returned page (string) contains any @var{html-strings} +@dots{} followed by a manual link to @var{uri}, in case the browser does not +forward automatically. +@end defun + +@defun http:serve-query serve-proc input-port output-port +reads the @dfn{URI} and @dfn{query-string} from @var{input-port}. If the +@cindex URI +@cindex query-string +query is a valid @samp{"POST"} or @samp{"GET"} query, then @code{http:serve-query} calls +@var{serve-proc} with three arguments, the @var{request-line}, @var{query-string}, +and @var{header-alist}. Otherwise, @code{http:serve-query} calls @var{serve-proc} with the +@var{request-line}, #f, and @var{header-alist}. + +If @var{serve-proc} returns a string, it is sent to @var{output-port}. If @var{serve-proc} returns a list, +then an error page with number 525 and strings from the list. If @var{serve-proc} +returns #f, then a @samp{Bad Request} (400) page is sent to @var{output-port}. + +Otherwise, @code{http:serve-query} replies (to @var{output-port}) with appropriate HTML describing the +problem. +@end defun + + +This example services HTTP queries from @var{port-number}: +@example + +(define socket (make-stream-socket AF_INET 0)) +(and (socket:bind socket port-number) ; AF_INET INADDR_ANY + (socket:listen socket 10) ; Queue up to 10 requests. + (dynamic-wind + (lambda () #f) + (lambda () + (do ((port (socket:accept socket) (socket:accept socket))) + (#f) + (let ((iport (duplicate-port port "r")) + (oport (duplicate-port port "w"))) + (http:serve-query build:serve iport oport) + (close-port iport) + (close-port oport)) + (close-port port))) + (lambda () (close-port socket)))) +@end example + + +@defun cgi:serve-query serve-proc +reads the @dfn{URI} and @dfn{query-string} from +@cindex URI +@cindex query-string +@code{(current-input-port)}. If the query is a valid @samp{"POST"} +or @samp{"GET"} query, then @code{cgi:serve-query} calls @var{serve-proc} with three arguments, the +@var{request-line}, @var{query-string}, and @var{header-alist}. +Otherwise, @code{cgi:serve-query} calls @var{serve-proc} with the @var{request-line}, #f, and +@var{header-alist}. + +If @var{serve-proc} returns a string, it is sent to @code{(current-input-port)}. +If @var{serve-proc} returns a list, then an error page with number 525 and strings +from the list. If @var{serve-proc} returns #f, then a @samp{Bad Request} (400) +page is sent to @code{(current-input-port)}. + +Otherwise, @code{cgi:serve-query} replies (to @code{(current-input-port)}) with +appropriate HTML describing the problem. +@end defun + +@defun make-query-alist-command-server rdb command-table + + +@defunx make-query-alist-command-server rdb command-table #t + +Returns a procedure of one argument. When that procedure is called +with a @var{query-alist} (as returned by @code{uri:decode-query}, the +value of the @samp{*command*} association will be the command invoked +in @var{command-table}. If @samp{*command*} is not in the @var{query-alist} then the +value of @samp{*suggest*} is tried. If neither name is in the +@var{query-alist}, then the literal value @samp{*default*} is tried in +@var{command-table}. + +If optional third argument is non-false, then the command is called +with just the parameter-list; otherwise, command is called with the +arguments described in its table. +@end defun |