1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
import os
from base import *
DIR = "/SCGI2/"
MAGIC = "Cherokee and SCGI rocks!"
PORT = get_free_port()
SCRIPT = """
from pyscgi import *
class TestHandler (SCGIHandler):
def handle_request (self):
self.handle_post()
self.output.write('Content-Type: text/plain\\r\\n\\r\\n')
self.output.write('Post: %%s\\n' %% (self.post))
SCGIServer(TestHandler, port=%d).serve_forever()
""" % (PORT)
CONF = """
vserver!default!rule!1270!match = directory
vserver!default!rule!1270!match!directory = <dir>
vserver!default!rule!1270!handler = scgi
vserver!default!rule!1270!handler!balancer = round_robin
vserver!default!rule!1270!handler!balancer!type = interpreter
vserver!default!rule!1270!handler!balancer!local_scgi2!host = localhost:%d
vserver!default!rule!1270!handler!balancer!local_scgi2!interpreter = %s %s
"""
class Test (TestBase):
def __init__ (self):
TestBase.__init__ (self)
self.name = "SCGI II: Post"
self.request = "POST %s HTTP/1.0\r\n" %(DIR) +\
"Content-type: application/x-www-form-urlencoded\r\n" +\
"Content-length: %d\r\n" % (len(MAGIC))
self.post = MAGIC
self.expected_error = 200
self.expected_content = "Post: "+MAGIC
self.forbidden_content = ["pyscgi", "SCGIServer", "write"]
def Prepare (self, www):
scgi_file = self.WriteFile (www, "scgi_test2.scgi", 0444, SCRIPT)
pyscgi = os.path.join (www, 'pyscgi.py')
if not os.path.exists (pyscgi):
self.CopyFile ('pyscgi.py', pyscgi)
self.conf = CONF % (PORT, look_for_python(), scgi_file)
self.conf = self.conf.replace ('<dir>', DIR)
|