/
opt
/
imh-python
/
lib
/
python3.9
/
site-packages
/
cherrypy
/
test
/
/opt/imh-python/lib/python3.9/site-packages/cherrypy/test
mkdir
upload
Name
Size
Mode
Actions
static/
-
0755
rm
__pycache__/
-
0755
rm
benchmark.py
12563
0644
edit
dl
rm
checkerdemo.py
1861
0644
edit
dl
rm
fastcgi.conf
686
0644
edit
dl
rm
fcgi.conf
486
0644
edit
dl
rm
helper.py
16369
0644
edit
dl
rm
logtest.py
8151
0644
edit
dl
rm
modfastcgi.py
4652
0644
edit
dl
rm
modfcgid.py
4237
0644
edit
dl
rm
modpy.py
4978
0644
edit
dl
rm
modwsgi.py
4834
0644
edit
dl
rm
sessiondemo.py
5425
0644
edit
dl
rm
style.css
17
0644
edit
dl
rm
test.pem
2254
0644
edit
dl
rm
test_auth_basic.py
4499
0644
edit
dl
rm
test_auth_digest.py
4454
0644
edit
dl
rm
test_bus.py
9960
0644
edit
dl
rm
test_caching.py
14386
0644
edit
dl
rm
test_config.py
8836
0644
edit
dl
rm
test_config_server.py
4037
0644
edit
dl
rm
test_conn.py
30744
0644
edit
dl
rm
test_core.py
30408
0644
edit
dl
rm
test_dynamicobjectmapping.py
12331
0644
edit
dl
rm
test_encoding.py
17535
0644
edit
dl
rm
test_etags.py
3093
0644
edit
dl
rm
test_http.py
10939
0644
edit
dl
rm
test_httputil.py
2412
0644
edit
dl
rm
test_iterator.py
5724
0644
edit
dl
rm
test_json.py
2860
0644
edit
dl
rm
test_logging.py
8315
0644
edit
dl
rm
test_mime.py
4538
0644
edit
dl
rm
test_misc_tools.py
7094
0644
edit
dl
rm
test_native.py
971
0644
edit
dl
rm
test_objectmapping.py
14504
0644
edit
dl
rm
test_params.py
1862
0644
edit
dl
rm
test_plugins.py
334
0644
edit
dl
rm
test_proxy.py
5630
0644
edit
dl
rm
test_refleaks.py
1555
0644
edit
dl
rm
test_request_obj.py
37097
0644
edit
dl
rm
test_routes.py
2583
0644
edit
dl
rm
test_session.py
17949
0644
edit
dl
rm
test_sessionauthenticate.py
2013
0644
edit
dl
rm
test_states.py
16703
0644
edit
dl
rm
test_static.py
16702
0644
edit
dl
rm
test_tools.py
17851
0644
edit
dl
rm
test_tutorials.py
6964
0644
edit
dl
rm
test_virtualhost.py
4021
0644
edit
dl
rm
test_wsgiapps.py
3997
0644
edit
dl
rm
test_wsgi_ns.py
2812
0644
edit
dl
rm
test_wsgi_unix_socket.py
2228
0644
edit
dl
rm
test_wsgi_vhost.py
1034
0644
edit
dl
rm
test_xmlrpc.py
4584
0644
edit
dl
rm
webtest.py
262
0644
edit
dl
rm
_test_decorators.py
951
0644
edit
dl
rm
_test_states_demo.py
1876
0644
edit
dl
rm
__init__.py
396
0644
edit
dl
rm
Edit:
/opt/imh-python/lib/python3.9/site-packages/cherrypy/test/modfastcgi.py
(4652B)
"""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. """ import os import re import cherrypy from cherrypy.process import servers from cherrypy.test import helper curdir = os.path.join(os.getcwd(), os.path.dirname(__file__)) def read_process(cmd, args=''): pipein, pipeout = os.popen4('%s %s' % (cmd, args)) try: firstline = pipeout.readline() if (re.search(r'(not recognized|No such file|not found)', firstline, re.IGNORECASE)): raise IOError('%s must be on your system path.' % cmd) output = firstline + pipeout.read() finally: pipeout.close() return output APACHE_PATH = 'apache2ctl' CONF_PATH = 'fastcgi.conf' conf_fastcgi = """ # Apache2 server conf file for testing CherryPy with mod_fastcgi. # fumanchu: I had to hard-code paths due to crazy Debian layouts :( ServerRoot /usr/lib/apache2 User #1000 ErrorLog %(root)s/mod_fastcgi.error.log DocumentRoot "%(root)s" ServerName 127.0.0.1 Listen %(port)s LoadModule fastcgi_module modules/mod_fastcgi.so LoadModule rewrite_module modules/mod_rewrite.so Options +ExecCGI SetHandler fastcgi-script RewriteEngine On RewriteRule ^(.*)$ /fastcgi.pyc [L] FastCgiExternalServer "%(server)s" -host 127.0.0.1:4000 """ def erase_script_name(environ, start_response): environ['SCRIPT_NAME'] = '' return cherrypy.tree(environ, start_response) class ModFCGISupervisor(helper.LocalWSGISupervisor): httpserver_class = 'cherrypy.process.servers.FlupFCGIServer' using_apache = True using_wsgi = True template = conf_fastcgi def __str__(self): return 'FCGI Server on %s:%s' % (self.host, self.port) def start(self, modulename): cherrypy.server.httpserver = servers.FlupFCGIServer( application=erase_script_name, bindAddress=('127.0.0.1', 4000)) cherrypy.server.httpserver.bind_addr = ('127.0.0.1', 4000) cherrypy.server.socket_port = 4000 # For FCGI, we both start apache... self.start_apache() # ...and our local server cherrypy.engine.start() self.sync_apps() def start_apache(self): fcgiconf = CONF_PATH if not os.path.isabs(fcgiconf): fcgiconf = os.path.join(curdir, fcgiconf) # Write the Apache conf file. f = open(fcgiconf, 'wb') try: server = repr(os.path.join(curdir, 'fastcgi.pyc'))[1:-1] output = self.template % {'port': self.port, 'root': curdir, 'server': server} output = output.replace('\r\n', '\n') f.write(output) finally: f.close() result = read_process(APACHE_PATH, '-k start -f %s' % fcgiconf) if result: print(result) def stop(self): """Gracefully shutdown a server that is serving forever.""" read_process(APACHE_PATH, '-k stop') helper.LocalWSGISupervisor.stop(self) def sync_apps(self): cherrypy.server.httpserver.fcgiserver.application = self.get_app( erase_script_name)
Save
cmd:
run