Ralf Schmitt  committed ab959e1

unify _do_read and _chunked_read in pywsgi

this makes the code a bit cleaner and it's easier to check if we're
using readline in _do_read. we need to do that in order to check for
short post requests.

  • Participants
  • Parent commits 21c16a9
  • Branches default

Comments (0)

Files changed (1)

File gevent/

             self.socket = None
-    def _do_read(self, reader, length=None):
+    def _do_read(self, length=None, use_readline=False):
+        if use_readline:
+            reader = self.rfile.readline
+        else:
+            reader =
         content_length = self.content_length
         if content_length is None:
             # Either Content-Length or "Transfer-Encoding: chunked" must be present in a request with a body
         self.position += len(read)
         return read
-    def _chunked_read(self, rfile, length=None, use_readline=False):
+    def _chunked_read(self, length=None, use_readline=False):
+        rfile = self.rfile
         if length == 0:
     def read(self, length=None):
         if self.chunked_input:
-            return self._chunked_read(self.rfile, length)
-        return self._do_read(, length)
+            return self._chunked_read(length)
+        return self._do_read(length)
     def readline(self, size=None):
         if self.chunked_input:
-            return self._chunked_read(self.rfile, size, True)
+            return self._chunked_read(size, True)
-            return self._do_read(self.rfile.readline, size)
+            return self._do_read(size, use_readline=True)
     def readlines(self, hint=None):
         return list(self)