From 12273fa947ec7c58b4d5e830aaa8e6538e1674b1 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 23 Sep 2006 13:04:37 +0000 Subject: [PATCH] Reverting r3805 whilst I track down a potential problem with it. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3806 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- AUTHORS | 1 - django/core/handlers/wsgi.py | 26 +------------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/AUTHORS b/AUTHORS index 8959a3a746..88db9bdbf9 100644 --- a/AUTHORS +++ b/AUTHORS @@ -100,7 +100,6 @@ answer newbie questions, and generally made Django that much better: lakin.wecker@gmail.com Stuart Langridge Eugene Lazutkin - Jeong-Min Lee Christopher Lenz limodou Martin Maney diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py index ced236c345..bf9df57cd6 100644 --- a/django/core/handlers/wsgi.py +++ b/django/core/handlers/wsgi.py @@ -4,11 +4,6 @@ from django.dispatch import dispatcher from django.utils import datastructures from django import http from pprint import pformat -from shutil import copyfileobj -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html STATUS_CODE_TEXT = { @@ -55,21 +50,6 @@ STATUS_CODE_TEXT = { 505: 'HTTP VERSION NOT SUPPORTED', } -def safe_copyfileobj(fsrc, fdst, length=16*1024, size=0): - """ - A version of shutil.copyfileobj that will not read more than 'size' bytes. - This makes it safe from clients sending more than CONTENT_LENGTH bytes of - data in the body. - """ - if not size: - return copyfileobj(fsrc, fdst, length) - while size > 0: - buf = fsrc.read(min(length, remain)) - if not buf: - break - fdst.write(buf) - size -= len(buf) - class WSGIRequest(http.HttpRequest): def __init__(self, environ): self.environ = environ @@ -139,11 +119,7 @@ class WSGIRequest(http.HttpRequest): try: return self._raw_post_data except AttributeError: - buf = StringIO() - content_length = int(self.environ['CONTENT_LENGTH']) - safe_copyfileobj(self.environ['wsgi.input'], buf, size=content_length) - self._raw_post_data = buf.getvalue() - buf.close() + self._raw_post_data = self.environ['wsgi.input'].read(int(self.environ["CONTENT_LENGTH"])) return self._raw_post_data GET = property(_get_get, _set_get)