From d5cb6691725f855fba9efa9c161f899d3ece3f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Sun, 5 Mar 2017 22:32:42 +0200 Subject: [PATCH] /bounce handles long payloads. --- hc/api/tests/test_bounce.py | 6 ++++++ hc/api/views.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/hc/api/tests/test_bounce.py b/hc/api/tests/test_bounce.py index 8b4b4d1d..da858de2 100644 --- a/hc/api/tests/test_bounce.py +++ b/hc/api/tests/test_bounce.py @@ -34,3 +34,9 @@ class BounceTestCase(BaseTestCase): url = "/api/v1/notifications/%s/bounce" % self.n.code r = self.client.post(url, "foo", content_type="text/plain") self.assertEqual(r.status_code, 400) + + def test_it_handles_long_payload(self): + url = "/api/v1/notifications/%s/bounce" % self.n.code + payload = "A" * 500 + r = self.client.post(url, payload, content_type="text/plain") + self.assertEqual(r.status_code, 200) diff --git a/hc/api/views.py b/hc/api/views.py index 36ce3a16..91607e93 100644 --- a/hc/api/views.py +++ b/hc/api/views.py @@ -190,7 +190,7 @@ def bounce(request, code): if td.total_seconds() > 600: return HttpResponseBadRequest() - notification.error = request.body + notification.error = request.body[:200] notification.save() return HttpResponse()