From dbed251fb9e514c8d244a03eb1c84aed9ddb0988 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 24 Jul 2012 12:18:14 +1200 Subject: Add a raw modifier to requests and responses, which turn off automatic additions. For now, this just turns off adding a Content-Length header when a body is specified. --- test/test_rparse.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'test/test_rparse.py') diff --git a/test/test_rparse.py b/test/test_rparse.py index 70395bdc..24ca3653 100644 --- a/test/test_rparse.py +++ b/test/test_rparse.py @@ -109,13 +109,17 @@ class TestMisc: assert e.parseString('"/foo"')[0].value.val == "/foo" e = rparse.Path("/foo") assert e.value.val == "/foo" - + def test_method(self): e = rparse.Method.expr() assert e.parseString("get")[0].value.val == "GET" assert e.parseString("'foo'")[0].value.val == "foo" assert e.parseString("'get'")[0].value.val == "get" + def test_raw(self): + e = rparse.Raw.expr() + assert e.parseString("r")[0] + def test_body(self): e = rparse.Body.expr() v = e.parseString("b'foo'")[0] @@ -436,6 +440,17 @@ class TestResponse: r = rparse.parse_response({}, "400'msg'") assert r.serve(s) + def test_raw(self): + s = cStringIO.StringIO() + r = rparse.parse_response({}, "400:b'foo'") + r.serve(s) + assert "Content-Length" in s.getvalue() + + s = cStringIO.StringIO() + r = rparse.parse_response({}, "400:b'foo':r") + r.serve(s) + assert not "Content-Length" in s.getvalue() + def test_length(self): def testlen(x): s = cStringIO.StringIO() -- cgit v1.2.3