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
474780f9
Commit
474780f9
authored
Aug 26, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove 405 method not allowed ImmediateResponse
parent
39288021
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
12 deletions
+15
-12
djangorestframework/exceptions.py
+12
-4
djangorestframework/request.py
+2
-4
djangorestframework/views.py
+1
-4
No files found.
djangorestframework/exceptions.py
View file @
474780f9
...
@@ -17,12 +17,20 @@ class PermissionDenied(Exception):
...
@@ -17,12 +17,20 @@ class PermissionDenied(Exception):
self
.
detail
=
detail
or
self
.
default_detail
self
.
detail
=
detail
or
self
.
default_detail
class
MethodNotAllowed
(
Exception
):
status_code
=
status
.
HTTP_405_METHOD_NOT_ALLOWED
default_detail
=
"Method '
%
s' not allowed"
def
__init__
(
self
,
method
,
detail
):
self
.
detail
=
(
detail
or
self
.
default_detail
)
%
method
class
UnsupportedMediaType
(
Exception
):
class
UnsupportedMediaType
(
Exception
):
status_code
=
415
status_code
=
status
.
HTTP_415_UNSUPPORTED_MEDIA_TYPE
default_detail
=
'Unsupported media type in request'
default_detail
=
"Unsupported media type '
%
s' in request"
def
__init__
(
self
,
detail
=
None
):
def
__init__
(
self
,
media_type
,
detail
=
None
):
self
.
detail
=
detail
or
self
.
default_detail
self
.
detail
=
(
detail
or
self
.
default_detail
)
%
media_type
# class Throttled(Exception):
# class Throttled(Exception):
# def __init__(self, detail):
# def __init__(self, detail):
...
...
djangorestframework/request.py
View file @
474780f9
...
@@ -207,8 +207,7 @@ class Request(object):
...
@@ -207,8 +207,7 @@ class Request(object):
"""
"""
Parse the request content.
Parse the request content.
May raise a 415 ImmediateResponse (Unsupported Media Type), or a
May raise an `UnsupportedMediaType`, or `ParseError` exception.
400 ImmediateResponse (Bad Request).
"""
"""
if
self
.
stream
is
None
or
self
.
content_type
is
None
:
if
self
.
stream
is
None
or
self
.
content_type
is
None
:
return
(
None
,
None
)
return
(
None
,
None
)
...
@@ -217,8 +216,7 @@ class Request(object):
...
@@ -217,8 +216,7 @@ class Request(object):
if
parser
.
can_handle_request
(
self
.
content_type
):
if
parser
.
can_handle_request
(
self
.
content_type
):
return
parser
.
parse
(
self
.
stream
,
self
.
META
,
self
.
upload_handlers
)
return
parser
.
parse
(
self
.
stream
,
self
.
META
,
self
.
upload_handlers
)
raise
UnsupportedMediaType
(
"Unsupported media type in request '
%
s'"
%
raise
UnsupportedMediaType
(
self
.
_content_type
)
self
.
_content_type
)
def
_authenticate
(
self
):
def
_authenticate
(
self
):
"""
"""
...
...
djangorestframework/views.py
View file @
474780f9
...
@@ -147,10 +147,7 @@ class View(DjangoView):
...
@@ -147,10 +147,7 @@ class View(DjangoView):
Return an HTTP 405 error if an operation is called which does not have
Return an HTTP 405 error if an operation is called which does not have
a handler method.
a handler method.
"""
"""
content
=
{
raise
exceptions
.
MethodNotAllowed
(
request
.
method
)
'detail'
:
"Method '
%
s' not allowed."
%
request
.
method
}
raise
ImmediateResponse
(
content
,
status
.
HTTP_405_METHOD_NOT_ALLOWED
)
@property
@property
def
_parsed_media_types
(
self
):
def
_parsed_media_types
(
self
):
...
...
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