diff --git a/NEWS b/NEWS index e1027333..ad031d52 100644 --- a/NEWS +++ b/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: diff --git a/test/htdocs/tests.py b/test/htdocs/tests.py index a11ac4c8..07c051e9 100644 --- a/test/htdocs/tests.py +++ b/test/htdocs/tests.py @@ -52,7 +52,7 @@ # information on the Apache Software Foundation, please see # . # - # $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 @@ -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" diff --git a/test/test.py b/test/test.py index 02b9e996..1a573214 100644 --- a/test/test.py +++ b/test/test.py @@ -52,7 +52,7 @@ # information on the Apache Software Foundation, please see # . # - # $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 $ # """ @@ -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("*", @@ -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"))