summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--waitress/channel.py2
-rw-r--r--waitress/tests/test_channel.py40
2 files changed, 41 insertions, 1 deletions
diff --git a/waitress/channel.py b/waitress/channel.py
index 702feae..66cccb9 100644
--- a/waitress/channel.py
+++ b/waitress/channel.py
@@ -62,7 +62,7 @@ class HTTPServerChannel(asyncore.dispatcher, object):
adj=None,
map=None, # test shim
):
- if map is None:
+ if map is None: # pragma: no cover
map = asyncore.socket_map
self.addr = addr
if adj is None:
diff --git a/waitress/tests/test_channel.py b/waitress/tests/test_channel.py
index f388039..308e798 100644
--- a/waitress/tests/test_channel.py
+++ b/waitress/tests/test_channel.py
@@ -333,6 +333,39 @@ class TestHTTPServerChannel(unittest.TestCase):
self.assertEqual(inst.server.tasks, [inst])
self.assertEqual(len(inst.tasks), 1)
+ def test_received_preq_not_completed(self):
+ inst, sock, map = self._makeOneWithMap()
+ inst.server = DummyServer()
+ preq = DummyParser()
+ inst.proto_request = preq
+ preq.completed = False
+ preq.empty = True
+ inst.received('GET / HTTP/1.1\n\n')
+ self.assertEqual(inst.server.tasks, [])
+
+ def test_received_preq_completed(self):
+ inst, sock, map = self._makeOneWithMap()
+ inst.server = DummyServer()
+ preq = DummyParser()
+ inst.proto_request = preq
+ preq.completed = True
+ preq.empty = True
+ inst.received('GET / HTTP/1.1\n\n')
+ self.assertEqual(inst.proto_request, None)
+ self.assertEqual(inst.server.tasks, [])
+
+ def test_received_preq_completed_n_lt_data(self):
+ inst, sock, map = self._makeOneWithMap()
+ inst.server = DummyServer()
+ preq = DummyParser()
+ inst.proto_request = preq
+ preq.completed = True
+ preq.empty = True
+ preq.retval = 1
+ inst.received('GET / HTTP/1.1\n\n')
+ self.assertEqual(inst.proto_request, None)
+ self.assertEqual(inst.server.tasks, [inst])
+
def test_handle_request(self):
req = DummyParser()
inst, sock, map = self._makeOneWithMap()
@@ -487,6 +520,13 @@ class DummyServer(object):
class DummyParser(object):
version = 1
+ data = None
+ completed = True
+ empty = False
+ retval = 1000
+ def received(self, data):
+ self.data = data
+ return self.retval
class DummyTask(object):
serviced = False