Blob Blame History Raw
From 4b478e1a6651f33b36e30294c5a320388ed527f4 Mon Sep 17 00:00:00 2001
From: benoitc <bchesneau@gmail.com>
Date: Fri, 3 Aug 2012 06:27:26 +0200
Subject: [PATCH] fix request line check. close #390

We never had the possibility to check the limit since we were quitting
the loop before it.
---
 gunicorn/http/message.py |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gunicorn/http/message.py b/gunicorn/http/message.py
index e2c7500..d2361ca 100644
--- a/gunicorn/http/message.py
+++ b/gunicorn/http/message.py
@@ -165,13 +165,14 @@ def parse(self, unreader):
             idx = data.find("\r\n")
             if idx >= 0:
                 break
-
-            if len(data) - 2 > self.limit_request_line > 0:
-                raise LimitRequestLine(len(data), self.limit_request_line)
-
             self.get_data(unreader, buf)
             data = buf.getvalue()
 
+            # check if the request line is too large
+            if len(data) - 2 > self.limit_request_line and \
+                    self.limit_request_line> 0 :
+                raise LimitRequestLine(len(data), self.limit_request_line)
+
         self.parse_request_line(data[:idx])
         buf = StringIO()
         buf.write(data[idx+2:]) # Skip \r\n
-- 
1.7.10