diff options
-rw-r--r-- | netlib/http/request.py | 5 | ||||
-rw-r--r-- | test/netlib/http/test_request.py | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/netlib/http/request.py b/netlib/http/request.py index 99662732..1a9b6f18 100644 --- a/netlib/http/request.py +++ b/netlib/http/request.py @@ -147,7 +147,10 @@ class Request(Message): HTTP request path, e.g. "/index.html". Guaranteed to start with a slash. """ - return _native(self.data.path) + if self.data.path is None: + return None + else: + return _native(self.data.path) @path.setter def path(self, path): diff --git a/test/netlib/http/test_request.py b/test/netlib/http/test_request.py index 5672259e..50ad2d05 100644 --- a/test/netlib/http/test_request.py +++ b/test/netlib/http/test_request.py @@ -41,7 +41,12 @@ class TestRequestCore(object): _test_passthrough_attr(treq(), "port") def test_path(self): - _test_decoded_attr(treq(), "path") + req = treq() + _test_decoded_attr(req, "path") + # path can also be None. + req.path = None + assert req.path is None + assert req.data.path is None def test_host(self): if six.PY2: |