Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/fastcgi|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. [[tags: egg]] == fastcgi [[toc:]] === Description Bindings for the FCGX API of libfcgi. === Author [[mailto:a.drummond@ucl.ac.uk|Alex Drummond]] ==== Usage (use fastcgi) === Documentation This egg provides a high-level interface to the FCGX API of libfcgi, part of the [[http://www.fastcgi.com/devkit/doc/overview.html|FastCGI Devkit]]. ==== fcgi-accept-loop <procedure>(fcgi-accept-loop SOCKET/PORT BACKLOG CALLBACK)</procedure> Given either the filename of a UNIX local socket (string) or a port (integer) as its first argument, this procedure opens a socket and starts a loop for accepting FastCGI requests. An exception is raised if there is an error opening/listening on the socket. Every time a request is accepted, the CALLBACK argument is called with four procedure arguments which will be refered to as 'in', 'out', 'err' and 'env' in the documentation below. The BACKLOG argument is passed to the [[http://www.die.net/doc/linux/man/man3/listen.3.html|listen]] system call. If the callback returns {{#f}}, the accept loop is terminated. ===== in <procedure>(in [INT])</procedure> [This procedure is passed to the CALLBACK argument of {{fcgi-accept-loop}}.] If called with no arguments, this procedure reads in as much data as possible from the input stream, returning {{#f}} if the stream is empty, and a string otherwise. If called with a single integer argument, it reads exactly the specified number of characters from the stream (and will block indefinitely if the stream is empty or contains too few characters). In either case, an exception is raised if there is an error reading from the stream. Don't use {{(in)}} to read in post data, since there is no guarantee that it will read all of it. Instead, call {{in}} with the value of the {{HTTP_CONTENT_LENGTH}} environment variable, or use the {{fcgi-get-post-data}} procedure. The variable {{*fcgi-slurp-chunk-size*}} determines the size of the input buffer which will be allocated by a zero-argument call to {{in}}. The value of this variable does not affect the maximum amount of input which can be read in, since additional buffers are automatically allocated as necessary. ===== out <procedure>(out STRING)</procedure> [This procedure is passed to the {{CALLBACK}} argument of {{fcgi-accept-loop}}.] Writes {{STRING}} to the output stream, raising an exception if there is an error. Note: In order to pass output from functions that print to standard output instead of returning a string, such as sxml-transforms functions, you could encapsulate the function like this (out (with-output-to-string (lambda () <function>))) ===== err <procedure>(err STRING)</procedure> [This procedure is passed to the {{CALLBACK}} argument of {{fcgi-accept-loop}}.] Writes {{STRING}} to the error stream, raising an exception if there is an error. ===== env <procedure>(env [VARNAME [DEFAULT]])</procedure> [This procedure is passed to the {{CALLBACK}} argument of {{fcgi-accept-loop}}.] If called with no arguments, this procedure returns a list of {{(name . value)}} pairs giving the name and value of every variable in the environment. If called with a single argument {{VARNAME}}, it returns the value of the specified variable, or {{#f}}if that variable is not set. {{VARNAME}} may optionally be followed by a second argument, which specifies a default value to be returned if the variable is not set. {{(env X)}} is thus equivalent to {{(env X #f)}}. Note that this procedure cannot be called after another request has been accepted, since libfcgi does not maintain environments from previous requests (you will most likely get a segfault). However, an old environment can easily be saved if necessary by storing the return value of {{(env)}}. ==== fcgi-get-post-data <procedure>(fcgi-get-post-data IN ENV)</procedure> Given an {{IN}} procedure and an {{ENV}} procedure, this procedure returns a string containing the post data for the last request, or {{#f}} if the last request was not a post request. === Example A file named {{example.scm}} is included in the egg. === Changelog * 1.1.1 pointer->c-pointer fix; output strings can contain NULs (thanks to Peter Danenberg) * 1.1 Port to Chicken 4 * 1.0.1 Bug fix (thanks to Maria Rekouts) * 1.0 First version === License Copyright (c) 2006, Alex Drummond <a.d.drummond@googlemail.com>, with contributions from Maria Rekouts, Nikolay Zavaritsky and Joachim Schipper. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The name of the author(s) may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 21 from 14?