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
823eea2d
Commit
823eea2d
authored
May 29, 2017
by
Tom Christie
Committed by
GitHub
May 29, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5147 from imdark/patch-1
Improve memory footprint when reading large JSON requests.
parents
7de34cf1
cdeab1c4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
rest_framework/parsers.py
+3
-2
No files found.
rest_framework/parsers.py
View file @
823eea2d
...
@@ -6,6 +6,7 @@ on the request, such as form content or json encoded data.
...
@@ -6,6 +6,7 @@ on the request, such as form content or json encoded data.
"""
"""
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
import
codecs
import
json
import
json
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -61,8 +62,8 @@ class JSONParser(BaseParser):
...
@@ -61,8 +62,8 @@ class JSONParser(BaseParser):
encoding
=
parser_context
.
get
(
'encoding'
,
settings
.
DEFAULT_CHARSET
)
encoding
=
parser_context
.
get
(
'encoding'
,
settings
.
DEFAULT_CHARSET
)
try
:
try
:
d
ata
=
stream
.
read
()
.
decode
(
encoding
)
d
ecoded_stream
=
codecs
.
getreader
(
encoding
)(
stream
)
return
json
.
load
s
(
data
)
return
json
.
load
(
decoded_stream
)
except
ValueError
as
exc
:
except
ValueError
as
exc
:
raise
ParseError
(
'JSON parse error -
%
s'
%
six
.
text_type
(
exc
))
raise
ParseError
(
'JSON parse error -
%
s'
%
six
.
text_type
(
exc
))
...
...
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