import os from base import * DIR = "/SCGI2/" MAGIC = "Cherokee and SCGI rocks!" PORT = 5002 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!directory!!handler = scgi vserver!default!directory!!handler!balancer = round_robin vserver!default!directory!!handler!balancer!type = interpreter vserver!default!directory!!handler!balancer!local_scgi2!host = localhost:%d vserver!default!directory!!handler!balancer!local_scgi2!interpreter = %s %s vserver!default!directory!!priority = 1270 """ 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)