Skip to content

Commit

Permalink
Added a test for req.headers_out.
Browse files Browse the repository at this point in the history
  • Loading branch information
grisha committed Feb 12, 2003
1 parent c0b2b4d commit 5f5a0dc
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
6 changes: 6 additions & 0 deletions NEWS
@@ -1,3 +1,9 @@
Feb 12 2003 - Added a test for req.headers_out

Fixed a bug where None was added to sys.path

Tests for connection and server added

Jan 18 2003 - Between now and the last entry the following things took
place:

Expand Down
9 changes: 8 additions & 1 deletion test/htdocs/tests.py
Expand Up @@ -52,7 +52,7 @@
# information on the Apache Software Foundation, please see
# <http://www.apache.org/>.
#
# $Id: tests.py,v 1.24 2003/01/24 21:41:09 grisha Exp $
# $Id: tests.py,v 1.25 2003/02/12 16:10:13 grisha Exp $
#

# mod_python tests
Expand Down Expand Up @@ -647,6 +647,13 @@ def cleanup(data):

data.log_error(data.cleanup_data)

def req_headers_out(req):

req.headers_out["X-Test-Header"] = "test ok"
req.write("test ok")

return apache.OK

def srv_register_cleanup(req):

req.cleanup_data = "test ok"
Expand Down
33 changes: 32 additions & 1 deletion test/test.py
Expand Up @@ -52,7 +52,7 @@
# information on the Apache Software Foundation, please see
# <http://www.apache.org/>.
#
# $Id: test.py,v 1.27 2003/01/23 22:34:18 grisha Exp $
# $Id: test.py,v 1.28 2003/02/12 16:10:13 grisha Exp $
#

"""
Expand Down Expand Up @@ -567,6 +567,36 @@ def test_req_register_cleanup(self):
if log.find("test ok") == -1:
self.fail("Could not find test message in error_log")

def test_req_headers_out_conf(self):

c = VirtualHost("*",
ServerName("test_req_headers_out"),
DocumentRoot(DOCUMENT_ROOT),
Directory(DOCUMENT_ROOT,
SetHandler("python-program"),
PythonHandler("tests::req_headers_out"),
PythonDebug("On")))
return str(c)

def test_req_headers_out(self):

print "\n * Testing req.headers_out"

conn = httplib.HTTPConnection("127.0.0.1:%s" % PORT)
conn.putrequest("GET", "/tests.py", skip_host=1)
conn.putheader("Host", "test_req_headers_out:%s" % PORT)
conn.endheaders()
response = conn.getresponse()
h = response.getheader("x-test-header", None)
response.read()
conn.close()

if h is None:
self.fail("Could not find x-test-header")

if h != "test ok":
self.fail("x-test-header is there, but does not contain 'test ok'")

def test_util_fieldstorage_conf(self):

c = VirtualHost("*",
Expand Down Expand Up @@ -807,6 +837,7 @@ def testPerRequestTests(self):
perRequestSuite.addTest(PerRequestTestCase("test_req_readline"))
perRequestSuite.addTest(PerRequestTestCase("test_req_readlines"))
perRequestSuite.addTest(PerRequestTestCase("test_req_register_cleanup"))
perRequestSuite.addTest(PerRequestTestCase("test_req_headers_out"))
perRequestSuite.addTest(PerRequestTestCase("test_util_fieldstorage"))
perRequestSuite.addTest(PerRequestTestCase("test_postreadrequest"))
perRequestSuite.addTest(PerRequestTestCase("test_trans"))
Expand Down

0 comments on commit 5f5a0dc

Please sign in to comment.