diff --git a/django/http/__init__.py b/django/http/__init__.py
index ecb3912..0b13857 100644
a
|
b
|
class HttpRequest(object):
|
310 | 310 | self._post_parse_error = True |
311 | 311 | |
312 | 312 | def _load_post_and_files(self): |
313 | | # Populates self._post and self._files |
| 313 | """ Populates self._post and self._files if the content-type is a form type """ |
314 | 314 | if self.method != 'POST': |
315 | 315 | self._post, self._files = QueryDict('', encoding=self._encoding), MultiValueDict() |
316 | 316 | return |
… |
… |
class HttpRequest(object):
|
318 | 318 | self._mark_post_parse_error() |
319 | 319 | return |
320 | 320 | |
321 | | if self.META.get('CONTENT_TYPE', '').startswith('multipart'): |
| 321 | if self.META.get('CONTENT_TYPE', '').startswith('multipart/form-data'): |
322 | 322 | if hasattr(self, '_body'): |
323 | 323 | # Use already read data |
324 | 324 | data = BytesIO(self._body) |
… |
… |
class HttpRequest(object):
|
336 | 336 | # empty POST |
337 | 337 | self._mark_post_parse_error() |
338 | 338 | raise |
339 | | else: |
| 339 | elif self.META.get('CONTENT_TYPE', '').startswith('application/x-www-form-urlencoded'): |
340 | 340 | self._post, self._files = QueryDict(self.body, encoding=self._encoding), MultiValueDict() |
| 341 | else: |
| 342 | self._post, self._files = QueryDict('', encoding=self._encoding), MultiValueDict() |
341 | 343 | |
342 | 344 | ## File-like and iterator interface. |
343 | 345 | ## |
diff --git a/tests/regressiontests/requests/tests.py b/tests/regressiontests/requests/tests.py
index f9e1112..fc26844 100644
a
|
b
|
class RequestsTests(unittest.TestCase):
|
265 | 265 | def test_stream(self): |
266 | 266 | payload = b'name=value' |
267 | 267 | request = WSGIRequest({'REQUEST_METHOD': 'POST', |
| 268 | 'CONTENT_TYPE': 'application/x-www-form-urlencoded', |
268 | 269 | 'CONTENT_LENGTH': len(payload), |
269 | 270 | 'wsgi.input': BytesIO(payload)}) |
270 | 271 | self.assertEqual(request.read(), b'name=value') |
… |
… |
class RequestsTests(unittest.TestCase):
|
276 | 277 | """ |
277 | 278 | payload = b'name=value' |
278 | 279 | request = WSGIRequest({'REQUEST_METHOD': 'POST', |
| 280 | 'CONTENT_TYPE': 'application/x-www-form-urlencoded', |
279 | 281 | 'CONTENT_LENGTH': len(payload), |
280 | 282 | 'wsgi.input': BytesIO(payload)}) |
281 | 283 | self.assertEqual(request.POST, {'name': ['value']}) |
… |
… |
class RequestsTests(unittest.TestCase):
|
289 | 291 | """ |
290 | 292 | payload = b'name=value' |
291 | 293 | request = WSGIRequest({'REQUEST_METHOD': 'POST', |
| 294 | 'CONTENT_TYPE': 'application/x-www-form-urlencoded', |
292 | 295 | 'CONTENT_LENGTH': len(payload), |
293 | 296 | 'wsgi.input': BytesIO(payload)}) |
294 | 297 | self.assertEqual(request.read(2), b'na') |
… |
… |
class RequestsTests(unittest.TestCase):
|
337 | 340 | 'wsgi.input': BytesIO(payload)}) |
338 | 341 | self.assertEqual(request.POST, {}) |
339 | 342 | |
| 343 | def test_POST_binary_only(self): |
| 344 | payload = b'\r\n\x01\x00\x00\x00ab\x00\x00\xcd\xcc,@' |
| 345 | request = WSGIRequest({'REQUEST_METHOD': 'POST', |
| 346 | 'CONTENT_TYPE': 'application/octet-stream', |
| 347 | 'CONTENT_LENGTH': len(payload), |
| 348 | 'wsgi.input': BytesIO(payload)}) |
| 349 | self.assertEqual(request.POST, {}) |
| 350 | self.assertEqual(request.FILES, {}) |
| 351 | self.assertEqual(request.body, payload) |
| 352 | |
340 | 353 | def test_read_by_lines(self): |
341 | 354 | payload = b'name=value' |
342 | 355 | request = WSGIRequest({'REQUEST_METHOD': 'POST', |
| 356 | 'CONTENT_TYPE': 'application/x-www-form-urlencoded', |
343 | 357 | 'CONTENT_LENGTH': len(payload), |
344 | 358 | 'wsgi.input': BytesIO(payload)}) |
345 | 359 | self.assertEqual(list(request), [b'name=value']) |
… |
… |
class RequestsTests(unittest.TestCase):
|
350 | 364 | """ |
351 | 365 | payload = b'name=value' |
352 | 366 | request = WSGIRequest({'REQUEST_METHOD': 'POST', |
| 367 | 'CONTENT_TYPE': 'application/x-www-form-urlencoded', |
353 | 368 | 'CONTENT_LENGTH': len(payload), |
354 | 369 | 'wsgi.input': BytesIO(payload)}) |
355 | 370 | raw_data = request.body |
… |
… |
class RequestsTests(unittest.TestCase):
|
362 | 377 | """ |
363 | 378 | payload = b'name=value' |
364 | 379 | request = WSGIRequest({'REQUEST_METHOD': 'POST', |
| 380 | 'CONTENT_TYPE': 'application/x-www-form-urlencoded', |
365 | 381 | 'CONTENT_LENGTH': len(payload), |
366 | 382 | 'wsgi.input': BytesIO(payload)}) |
367 | 383 | raw_data = request.body |
… |
… |
class RequestsTests(unittest.TestCase):
|
414 | 430 | |
415 | 431 | payload = b'name=value' |
416 | 432 | request = WSGIRequest({'REQUEST_METHOD': 'POST', |
| 433 | 'CONTENT_TYPE': 'application/x-www-form-urlencoded', |
417 | 434 | 'CONTENT_LENGTH': len(payload), |
418 | 435 | 'wsgi.input': ExplodingBytesIO(payload)}) |
419 | 436 | |