File: 198-HTTPresponse.py

package info (click to toggle)
cherokee 1.0.8-5%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 18,240 kB
  • ctags: 11,897
  • sloc: ansic: 60,631; python: 26,496; sh: 10,929; makefile: 2,759; php: 765; xml: 61; perl: 32; sed: 16
file content (33 lines) | stat: -rw-r--r-- 858 bytes parent folder | download
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
from base import *

DIR = "cgi-bin_httpresponse"
MSG = "Page eaten by dog"

CONF = """
vserver!1!rule!1980!match = directory
vserver!1!rule!1980!match!directory = /%s
vserver!1!rule!1980!handler = cgi
vserver!1!rule!1980!handler!error_handler = 0
""" % (DIR)

CGI_BASE = """#!/bin/sh
echo "Content-Type: text/plain"
echo "HTTP/1.0 404 %s"
echo "Foo: bar"
echo
echo "Sorry, file not found."
""" % (MSG)

class Test (TestBase):
    def __init__ (self):
        TestBase.__init__ (self, __file__)
        self.name = "CGI: HTTP response with reply headers"

        self.request           = "GET /%s/test HTTP/1.0\r\n" % (DIR)
        self.conf              = CONF
        self.expected_error    = 404
        self.forbidden_content = MSG

    def Prepare (self, www):
        self.Mkdir (www, DIR)
        self.WriteFile (www, "%s/test"%(DIR), 0755, CGI_BASE)