#15785: HttpRequest.read(NUM_BYTES) can read beyond the end of wsgi.input stream. (Violation of WSGI spec & under-defined behaviour) ---------------------------------------+----------------------------- Reporter: tomchristie | Owner: tomchristie Type: Bug | Status: new Milestone: 1.3 | Component: HTTP handling Version: 1.3-rc1 | Severity: Normal Resolution: | Keywords: http, wsgi Triage Stage: Accepted | Has patch: 1 Needs documentation: 0 | Needs tests: 0 Patch needs improvement: 0 | ---------------------------------------+-----------------------------
Comment (by isagalaev): Couple of comments, small nits, actually: {{{ + r = { + 'CONTENT_LENGTH': len(payload), + 'CONTENT_TYPE': client.MULTIPART_CONTENT, + 'PATH_INFO': "/file_uploads/echo/", + 'REQUEST_METHOD': 'POST', + 'wsgi.input': client.FakePayload(payload), + } }}} Django uses a different style in such cases: values should not be vertically aligned but separated from keys with a colon and a single space. {{{ + try: + content_length = int(self.environ.get('CONTENT_LENGTH', 0)) + except (ValueError, TypeError): + content_length = 0 }}} I don't see how TypeError can be raised here. Also, the default value is defined in two places. I'd do it like this instead: {{{ try: content_length = int(self.environ.get('CONTENT_LENGTH')) except ValueError: content_length = 0 }}} -- Ticket URL: <http://code.djangoproject.com/ticket/15785#comment:7> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.