Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 37 lines (31 sloc) 0.983 kb
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
from base import *

DIR = 'cgi_error_contentlength_1'
ERROR = 404
ERROR_MSG = letters_random(1234)

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

CGI_BASE = """#!/bin/sh
echo "Content-type: text/html"
echo "Content-Length: %d"
echo "Status: %s"
echo ""
cat << EOF
%s
EOF
"""

class Test (TestBase):
    def __init__ (self):
        TestBase.__init__ (self, __file__)
        self.name = "CGI error_handler: Content-Length"

        self.request = "GET /%s/exec.cgi HTTP/1.0\r\n" % (DIR)
        self.expected_error = ERROR
        self.forbidden_content = "Content-Length: %d" % (len(ERROR_MSG))
        self.conf = CONF

    def Prepare (self, www):
        d = self.Mkdir (www, DIR)
        f = self.WriteFile (d, "exec.cgi", 0555,
                            CGI_BASE % (len(ERROR_MSG), ERROR, ERROR_MSG))
Something went wrong with that request. Please try again.