chickadee » spiffy-cgi-handlers

Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for 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 egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

Spiffy CGI Handlers

Description

Spiffy handlers which add support for CGI and derivatives (currently only FastCGI).

Author

The CGI code was originally written by Felix Winkelmann, the FastCGI code was written by Andy Bennett.

Current maintainers are Andy Bennett (FastCGI) and Peter Bex (CGI).

Requirements

Requires the intarweb, uri-common, socket, records and (of course) spiffy extensions.

FastCGI

Support for the FastCGI server-side specification. This allows you to run FastCGI client processes like Rails or PHP as backends to be accessed from Spiffy.

You can load it via the fcgi-handler module:

(use fcgi-handler)

Procedures

The fcgi-handler module exports two procedures:

fcgi-handler app-name #!key (continue #f)procedure

TODO: Document this.

fcgi-register-application name role filename socket prespawn maxspawnprocedure

TODO: Document this.

Role is one of the role constants fcgi-responder, fcgi-authorizer or fcgi-filter.

fcgi-responderconstant
fcgi-authorizerconstant
fcgi-filterconstant

Constants that store role identifiers for use in fcgi-register-application.

CGI

This egg includes support for the old-fashioned CGI/1.1 protocol, as specified by RFC 3875. It includes a few workarounds required for PHP as well.

You can load it via the cgi-handler module:

(use cgi-handler)

All request headers will be passed as environment variables to the CGI program, prefixed with "HTTP_", and converted to uppercase, with hyphens ("-") replaced by an underscore ("_"). The CGI program will receive the request body in unparsed form from stdin and should write a complete HTTP response to stdout. Any headers that are missing but required for HTTP will be added by Spiffy. For more info on how a CGI script is called, consult the spec.

The AUTH_TYPE and REMOTE_USER environment variables are currently not set during invocation of CGI subprocesses. The REMOTE_IDENT environment variable is not and never will be supported.

Procedures

The cgi-handler module exports two procedures:

cgi-handler filename #!optional interpreterprocedure

The cgi handler simply calls CGI scripts. It is assumed the requested file is executable if no interpreter is given. (If used as a regular handler, it will only receive the filename). If the filename is a relative path, it is assumed to be relative to (root-path). It's safer to store your scripts outside the docroot, though!

cgi-handler* #!optional interpreterprocedure

The cgi-handler* procedure is usually more useful. It allows you to define an interpreter to use for files and returns a new handler. See spiffy's example for file-extension-handlers.

Configuration

The CGI handler can be configured with the following parameters:

cgi-default-environment #!optional env-alistprocedure

The environment variables that should be in the default environnment of every CGI program. Variables like SCRIPT_NAME will be added dynamically to the end of this alist.

Default:

(("GATEWAY_INTERFACE" . "CGI/1.1"))

Repository

https://bitbucket.org/knodium/spiffy-cgi-handlers

Changelog

0.7

0.6

0.5

0.4

0.3

0.2

0.1

License

Two BSD-like licenses apply. For the Scheme code, a standard 3-clause BSD license applies:

 Copyright (c) 2012, Andy Bennett <andyjpb@knodium.com>
 Copyright (c) 2007-2009, 2016 Peter Bex
 Copyright (c) 2000-2005, Felix L. Winkelmann
 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.
 
 Neither the name of the author nor the names of its contributors may
 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 HOLDERS 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.

and, for the fastcgi C code the following license applies:

 
 This FastCGI application library source and object code (the
 "Software") and its documentation (the "Documentation") are
 copyrighted by Open Market, Inc ("Open Market").  The following terms
 apply to all files associated with the Software and Documentation
 unless explicitly disclaimed in individual files.
 
 Open Market permits you to use, copy, modify, distribute, and license
 this Software and the Documentation for any purpose, provided that
 existing copyright notices are retained in all copies and that this
 notice is included verbatim in any distributions.  No written
 agreement, license, or royalty fee is required for any of the
 authorized uses.  Modifications to this Software and Documentation may
 be copyrighted by their authors and need not follow the licensing
 terms described here.  If modifications to this Software and
 Documentation have new licensing terms, the new terms must be clearly
 indicated on the first page of each file where they apply.
 
 OPEN MARKET MAKES NO EXPRESS OR IMPLIED WARRANTY WITH RESPECT TO THE
 SOFTWARE OR THE DOCUMENTATION, INCLUDING WITHOUT LIMITATION ANY
 WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  IN
 NO EVENT SHALL OPEN MARKET BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY
 DAMAGES ARISING FROM OR RELATING TO THIS SOFTWARE OR THE
 DOCUMENTATION, INCLUDING, WITHOUT LIMITATION, ANY INDIRECT, SPECIAL OR
 CONSEQUENTIAL DAMAGES OR SIMILAR DAMAGES, INCLUDING LOST PROFITS OR
 LOST DATA, EVEN IF OPEN MARKET HAS BEEN ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGES.  THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS".
 OPEN MARKET HAS NO LIABILITY IN CONTRACT, TORT, NEGLIGENCE OR
 OTHERWISE ARISING OUT OF THIS SOFTWARE OR THE DOCUMENTATION.

Contents »