Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #20961 -- Fixed HttpResponse default empty content

Thanks epandurski at gmail.com for the report.
  • Loading branch information...
commit f4e9804567ce45ef01f6613ce194e96d293ac04b 1 parent f33db5a
@claudep claudep authored
Showing with 8 additions and 1 deletion.
  1. +1 −1  django/http/response.py
  2. +7 −0 tests/httpwrappers/tests.py
View
2  django/http/response.py
@@ -317,7 +317,7 @@ class HttpResponse(HttpResponseBase):
streaming = False
- def __init__(self, content='', *args, **kwargs):
+ def __init__(self, content=b'', *args, **kwargs):
super(HttpResponse, self).__init__(*args, **kwargs)
# Content is a bytestring. See the `content` property methods.
self.content = content
View
7 tests/httpwrappers/tests.py
@@ -385,6 +385,13 @@ def test_file_interface(self):
self.assertEqual(r.tell(), 6)
self.assertEqual(r.content, b'abcdef')
+ # with Content-Encoding header
+ r = HttpResponse()
+ r['Content-Encoding'] = 'winning'
+ r.write(b'abc')
+ r.write(b'def')
+ self.assertEqual(r.content, b'abcdef')
+
def test_unsafe_redirect(self):
bad_urls = [
'data:text/html,<script>window.alert("xss")</script>',
Please sign in to comment.
Something went wrong with that request. Please try again.