You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
lighttpd2/tests/t-header-modify.py

76 lines
2.1 KiB

# -*- coding: utf-8 -*-
from base import *
from requests import *
class TestHeaderAdd(CurlRequest):
# use capture from previous regex conditional
config = """
header.add "Test-Header" => "%{req.query}";
header.add "Test-Header" => "%{req.path}";
blank;
"""
URL = "/path?simple_query"
def CheckResponse(self):
h = map(lambda x: x[1], filter(lambda x: x[0] == "Test-Header", self.resp_header_list))
if len(h) != 2 or h[0] != "simple_query" or h[1] != "/path":
print >>Env.log, repr(h)
raise BaseException("Unexpected headers 'Test-Header'")
return True
class TestHeaderAppend(CurlRequest):
# use capture from previous regex conditional
config = """
header.append "Test-Header" => "%{req.query}";
header.append "Test-Header" => "%{req.path}";
blank;
"""
URL = "/path?simple_query"
def CheckResponse(self):
h = map(lambda x: x[1], filter(lambda x: x[0] == "Test-Header", self.resp_header_list))
if len(h) != 1 or h[0] != "simple_query, /path":
print >>Env.log, repr(h)
raise BaseException("Unexpected headers 'Test-Header'")
return True
class TestHeaderOverwrite(CurlRequest):
# use capture from previous regex conditional
config = """
header.overwrite "Test-Header" => "%{req.query}";
header.overwrite "Test-Header" => "%{req.path}";
blank;
"""
URL = "/path?simple_query"
def CheckResponse(self):
h = map(lambda x: x[1], filter(lambda x: x[0] == "Test-Header", self.resp_header_list))
if len(h) != 1 or h[0] != "/path":
print >>Env.log, repr(h)
raise BaseException("Unexpected headers 'Test-Header'")
return True
class TestHeaderRemove(CurlRequest):
# use capture from previous regex conditional
config = """
header.add "Test-Header" => "%{req.query}";
header.remove "Test-Header";
blank;
"""
URL = "/path?simple_query"
def CheckResponse(self):
h = map(lambda x: x[1], filter(lambda x: x[0] == "Test-Header", self.resp_header_list))
if len(h) != 0:
print >>Env.log, repr(h)
raise BaseException("Unexpected headers 'Test-Header'")
return True
class Test(GroupTest):
group = [
TestHeaderAdd,
TestHeaderAppend,
TestHeaderOverwrite,
TestHeaderRemove,
]