Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
2fe0e584
Commit
2fe0e584
authored
Apr 11, 2011
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start refactoring tests
parent
ec2a300a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
djangorestframework/request.py
+33
-0
No files found.
djangorestframework/request.py
View file @
2fe0e584
...
@@ -145,6 +145,39 @@ class RequestMixin(object):
...
@@ -145,6 +145,39 @@ class RequestMixin(object):
self
.
_stream
=
StringIO
(
content
[
self
.
CONTENT_PARAM
])
self
.
_stream
=
StringIO
(
content
[
self
.
CONTENT_PARAM
])
del
(
self
.
_raw_content
)
del
(
self
.
_raw_content
)
def
parse
(
self
,
stream
,
content_type
):
"""
Parse the request content.
May raise a 415 ResponseException (Unsupported Media Type),
or a 400 ResponseException (Bad Request).
"""
parsers
=
as_tuple
(
self
.
parsers
)
parser
=
None
for
parser_cls
in
parsers
:
if
parser_cls
.
handles
(
content_type
):
parser
=
parser_cls
(
self
)
break
if
parser
is
None
:
raise
ResponseException
(
status
.
HTTP_415_UNSUPPORTED_MEDIA_TYPE
,
{
'error'
:
'Unsupported media type in request
\'
%
s
\'
.'
%
content_type
.
media_type
})
return
parser
.
parse
(
stream
)
@property
def
parsed_media_types
(
self
):
"""Return an list of all the media types that this view can parse."""
return
[
parser
.
media_type
for
parser
in
self
.
parsers
]
@property
def
default_parser
(
self
):
"""Return the view's most preffered emitter.
(This has no behavioural effect, but is may be used by documenting emitters)"""
return
self
.
parsers
[
0
]
method
=
property
(
_get_method
,
_set_method
)
method
=
property
(
_get_method
,
_set_method
)
content_type
=
property
(
_get_content_type
,
_set_content_type
)
content_type
=
property
(
_get_content_type
,
_set_content_type
)
accept
=
property
(
_get_accept
,
_set_accept
)
accept
=
property
(
_get_accept
,
_set_accept
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment