mirror of https://github.com/django/django.git
Fixed #10687: fixed request parsing when upload_handlers is empty. Thanks, Armin Ronacher.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10723 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
88f5167142
commit
c40f715257
|
@ -1,5 +1,4 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -84,7 +84,8 @@ class MultiPartParser(object):
|
||||||
|
|
||||||
# For compatibility with low-level network APIs (with 32-bit integers),
|
# For compatibility with low-level network APIs (with 32-bit integers),
|
||||||
# the chunk size should be < 2^31, but still divisible by 4.
|
# the chunk size should be < 2^31, but still divisible by 4.
|
||||||
self._chunk_size = min(2**31-4, *[x.chunk_size for x in upload_handlers if x.chunk_size])
|
possible_sizes = [x.chunk_size for x in upload_handlers if x.chunk_size]
|
||||||
|
self._chunk_size = min([2**31-4] + possible_sizes)
|
||||||
|
|
||||||
self._meta = META
|
self._meta = META
|
||||||
self._encoding = encoding or settings.DEFAULT_CHARSET
|
self._encoding = encoding or settings.DEFAULT_CHARSET
|
||||||
|
|
|
@ -3,12 +3,14 @@ import os
|
||||||
import errno
|
import errno
|
||||||
import shutil
|
import shutil
|
||||||
import unittest
|
import unittest
|
||||||
|
from StringIO import StringIO
|
||||||
|
|
||||||
from django.core.files import temp as tempfile
|
from django.core.files import temp as tempfile
|
||||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||||
from django.test import TestCase, client
|
from django.test import TestCase, client
|
||||||
from django.utils import simplejson
|
from django.utils import simplejson
|
||||||
from django.utils.hashcompat import sha_constructor
|
from django.utils.hashcompat import sha_constructor
|
||||||
|
from django.http.multipartparser import MultiPartParser
|
||||||
|
|
||||||
from models import FileModel, temp_storage, UPLOAD_TO
|
from models import FileModel, temp_storage, UPLOAD_TO
|
||||||
import uploadhandler
|
import uploadhandler
|
||||||
|
@ -290,3 +292,13 @@ class DirectoryCreationTests(unittest.TestCase):
|
||||||
"%s exists and is not a directory." % UPLOAD_TO)
|
"%s exists and is not a directory." % UPLOAD_TO)
|
||||||
except:
|
except:
|
||||||
self.fail("IOError not raised")
|
self.fail("IOError not raised")
|
||||||
|
|
||||||
|
class MultiParserTests(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_empty_upload_handlers(self):
|
||||||
|
# We're not actually parsing here; just checking if the parser properly
|
||||||
|
# instantiates with empty upload handlers.
|
||||||
|
parser = MultiPartParser({
|
||||||
|
'CONTENT_TYPE': 'multipart/form-data; boundary=_foo',
|
||||||
|
'CONTENT_LENGTH': '1'
|
||||||
|
}, StringIO('x'), [], 'utf-8')
|
||||||
|
|
Loading…
Reference in New Issue