mirror of
				https://github.com/encode/django-rest-framework.git
				synced 2025-10-31 07:57:55 +03:00 
			
		
		
		
	Merge pull request #33 from astraw/master
bugfix for failed multipart parse on empty request
This commit is contained in:
		
						commit
						019cb7f7d7
					
				|  | @ -13,6 +13,7 @@ We need a method to be able to: | ||||||
| 
 | 
 | ||||||
| from django.http import QueryDict | from django.http import QueryDict | ||||||
| from django.http.multipartparser import MultiPartParser as DjangoMultiPartParser | from django.http.multipartparser import MultiPartParser as DjangoMultiPartParser | ||||||
|  | from django.http.multipartparser import MultiPartParserError | ||||||
| from django.utils import simplejson as json | from django.utils import simplejson as json | ||||||
| from djangorestframework import status | from djangorestframework import status | ||||||
| from djangorestframework.response import ErrorResponse | from djangorestframework.response import ErrorResponse | ||||||
|  | @ -135,6 +136,10 @@ class MultiPartParser(BaseParser): | ||||||
|         `files` will be a :class:`QueryDict` containing all the form files. |         `files` will be a :class:`QueryDict` containing all the form files. | ||||||
|         """ |         """ | ||||||
|         upload_handlers = self.view.request._get_upload_handlers() |         upload_handlers = self.view.request._get_upload_handlers() | ||||||
|         django_parser = DjangoMultiPartParser(self.view.request.META, stream, upload_handlers) |         try: | ||||||
|  |             django_parser = DjangoMultiPartParser(self.view.request.META, stream, upload_handlers) | ||||||
|  |         except MultiPartParserError, exc: | ||||||
|  |             raise ErrorResponse(status.HTTP_400_BAD_REQUEST, | ||||||
|  |                                 {'detail': 'multipart parse error - %s' % unicode(exc)}) | ||||||
|         return django_parser.parse() |         return django_parser.parse() | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user