mirror of https://github.com/django/django.git
Fixed #20961 -- Fixed HttpResponse default empty content
Thanks epandurski at gmail.com for the report.
This commit is contained in:
parent
f33db5a09a
commit
f4e9804567
|
@ -317,7 +317,7 @@ class HttpResponse(HttpResponseBase):
|
||||||
|
|
||||||
streaming = False
|
streaming = False
|
||||||
|
|
||||||
def __init__(self, content='', *args, **kwargs):
|
def __init__(self, content=b'', *args, **kwargs):
|
||||||
super(HttpResponse, self).__init__(*args, **kwargs)
|
super(HttpResponse, self).__init__(*args, **kwargs)
|
||||||
# Content is a bytestring. See the `content` property methods.
|
# Content is a bytestring. See the `content` property methods.
|
||||||
self.content = content
|
self.content = content
|
||||||
|
|
|
@ -385,6 +385,13 @@ class HttpResponseTests(unittest.TestCase):
|
||||||
self.assertEqual(r.tell(), 6)
|
self.assertEqual(r.tell(), 6)
|
||||||
self.assertEqual(r.content, b'abcdef')
|
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):
|
def test_unsafe_redirect(self):
|
||||||
bad_urls = [
|
bad_urls = [
|
||||||
'data:text/html,<script>window.alert("xss")</script>',
|
'data:text/html,<script>window.alert("xss")</script>',
|
||||||
|
|
Loading…
Reference in New Issue