From 403ac82a7d07f08e931aedde4cbe4289b09d60ec Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sun, 20 Mar 2016 23:22:50 +0100 Subject: [PATCH] netlib: request.path can be None --- netlib/http/request.py | 5 ++++- 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 99662732e..1a9b6f18f 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 5672259ed..50ad2d058 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: