From 420979142b84b7c7f9e4ff98dbd1613c6d440c18 Mon Sep 17 00:00:00 2001 From: jpic Date: Wed, 15 Jun 2016 22:24:36 +0200 Subject: [PATCH] Test that malformed urls don't come back --- daphne/tests/test_http.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/daphne/tests/test_http.py b/daphne/tests/test_http.py index 7a412d9..6eb067b 100644 --- a/daphne/tests/test_http.py +++ b/daphne/tests/test_http.py @@ -55,3 +55,15 @@ class TestHTTPProtocol(TestCase): ) # Make sure that comes back right on the protocol self.assertEqual(self.tr.value(), b"HTTP/1.1 201 Created\r\nTransfer-Encoding: chunked\r\nX-Test: Boom!\r\n\r\n6\r\nOH HAI\r\n0\r\n\r\n") + + def test_malformed_url(self): + # Send malformed request to the protocol + self.proto.dataReceived( + b"GET /\x99 HTTP/1.1\r\n" + + b"Host: somewhere.com\r\n" + + b"\r\n" + ) + # Make sure that this doesn't come back + _, message = self.channel_layer.receive_many(["http.request"]) + self.assertIsNone(_) + self.assertIsNone(message)