diff options
| author | Tom Christie | 2011-04-11 12:19:28 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-04-11 12:19:28 +0100 |
| commit | 0fe8d1a15dab8c1da37b4e966ccfe9095f24fa76 (patch) | |
| tree | 42e7fa28d2cb63ba9a7123ea1ab351115f0ce339 /djangorestframework/request.py | |
| parent | e29a3f4cf12ea4c7cc616f27441b44639c736334 (diff) | |
| download | django-rest-framework-0fe8d1a15dab8c1da37b4e966ccfe9095f24fa76.tar.bz2 | |
form overloading tests passing
Diffstat (limited to 'djangorestframework/request.py')
| -rw-r--r-- | djangorestframework/request.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/djangorestframework/request.py b/djangorestframework/request.py index f79354a1..988c0592 100644 --- a/djangorestframework/request.py +++ b/djangorestframework/request.py @@ -1,6 +1,7 @@ from djangorestframework.mediatypes import MediaType from djangorestframework.utils import as_tuple from djangorestframework.response import ResponseException +from djangorestframework.parsers import FormParser, MultipartParser from djangorestframework import status #from djangorestframework.requestparsing import parse, load_parser @@ -151,11 +152,18 @@ class RequestMixin(object): if not self.USE_FORM_OVERLOADING or self.method != 'POST' or not self.content_type.is_form(): return + # Temporarily switch to using the form parsers, then parse the content + parsers = self.parsers + self.parsers = (FormParser, MultipartParser) content = self.RAW_CONTENT + self.parsers = parsers + + # Method overloading - change the method and remove the param from the content if self.METHOD_PARAM in content: self.method = content[self.METHOD_PARAM].upper() del self._raw_content[self.METHOD_PARAM] + # Content overloading - rewind the stream and modify the content type if self.CONTENT_PARAM in content and self.CONTENTTYPE_PARAM in content: self._content_type = MediaType(content[self.CONTENTTYPE_PARAM]) self._stream = StringIO(content[self.CONTENT_PARAM]) |
