cherrypy.test.modfastcgi module

Wrapper for mod_fastcgi, for use as a CherryPy HTTP server when testing.

To autostart fastcgi, the “apache” executable or script must be on your system path, or you must override the global APACHE_PATH. On some platforms, “apache” may be called “apachectl”, “apache2ctl”, or “httpd”–create a symlink to them if needed.

You’ll also need the WSGIServer from flup.servers. See http://projects.amor.org/misc/wiki/ModPythonGateway

KNOWN BUGS

  1. Apache processes Range headers automatically; CherryPy’s truncated

    output is then truncated again by Apache. See test_core.testRanges. This was worked around in http://www.cherrypy.org/changeset/1319.

  2. Apache does not allow custom HTTP methods like CONNECT as per the spec.

    See test_core.testHTTPMethods.

  3. Max request header and body settings do not work with Apache.

  4. Apache replaces status “reason phrases” automatically. For example,

    CherryPy may set “304 Not modified” but Apache will write out “304 Not Modified” (capital “M”).

  5. Apache does not allow custom error codes as per the spec.

  6. Apache (or perhaps modpython, or modpython_gateway) unquotes %xx in the

    Request-URI too early.

  7. mod_python will not read request bodies which use the “chunked”

    transfer-coding (it passes REQUEST_CHUNKED_ERROR to ap_setup_client_block instead of REQUEST_CHUNKED_DECHUNK, see Apache2’s http_protocol.c and mod_python’s requestobject.c).

  8. Apache will output a “Content-Length: 0” response header even if there’s

    no response entity body. This isn’t really a bug; it just differs from the CherryPy default.

class cherrypy.test.modfastcgi.ModFCGISupervisor(**kwargs)[source]

Bases: cherrypy.test.helper.LocalWSGISupervisor

httpserver_class = 'cherrypy.process.servers.FlupFCGIServer'
start(modulename)[source]

Load and start the HTTP server.

start_apache()[source]
stop()[source]

Gracefully shutdown a server that is serving forever.

sync_apps()[source]

Hook a new WSGI app into the origin server.

template = '\n# Apache2 server conf file for testing CherryPy with mod_fastcgi.\n# fumanchu: I had to hard-code paths due to crazy Debian layouts :(\nServerRoot /usr/lib/apache2\nUser #1000\nErrorLog %(root)s/mod_fastcgi.error.log\n\nDocumentRoot "%(root)s"\nServerName 127.0.0.1\nListen %(port)s\nLoadModule fastcgi_module modules/mod_fastcgi.so\nLoadModule rewrite_module modules/mod_rewrite.so\n\nOptions +ExecCGI\nSetHandler fastcgi-script\nRewriteEngine On\nRewriteRule ^(.*)$ /fastcgi.pyc [L]\nFastCgiExternalServer "%(server)s" -host 127.0.0.1:4000\n'
using_apache = True
using_wsgi = True
cherrypy.test.modfastcgi.erase_script_name(environ, start_response)[source]
cherrypy.test.modfastcgi.read_process(cmd, args='')[source]