Skip to content

Commit fd13816

Browse files
nateprewittsethmlarson
authored andcommitted
Revert "Fix for response with UTF-8 BOM #4976"
This reverts commit 19cff44. This reverts commit 9e27326. This reverts commit f507a3e.
1 parent 24bcb9e commit fd13816

3 files changed

Lines changed: 0 additions & 34 deletions

File tree

requests/models.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -856,9 +856,6 @@ def text(self):
856856
# Fallback to auto-detected encoding.
857857
if self.encoding is None:
858858
encoding = self.apparent_encoding
859-
# Forcefully remove BOM from UTF-8
860-
elif self.encoding.lower() == 'utf-8':
861-
encoding = 'utf-8-sig'
862859

863860
# Decode unicode from given encoding.
864861
try:

tests/test_testserver.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,36 +56,6 @@ def test_text_response(self):
5656
assert r.text == u'roflol'
5757
assert r.headers['Content-Length'] == '6'
5858

59-
def test_text_bom_response(self):
60-
"""the text_response_server sends the given text with UTF-8 BOM"""
61-
server = Server.text_response_server(
62-
"HTTP/1.1 200 OK\r\n" +
63-
"Content-Type: text/html; charset=UTF-8\r\n" +
64-
u'\r\n\ufeff<doctype html><html><body>ジェーピーニック</body></html>'
65-
)
66-
67-
with server as (host, port):
68-
r = requests.get('http://{}:{}'.format(host, port))
69-
70-
assert r.status_code == 200
71-
assert r.text == u'<doctype html><html><body>ジェーピーニック</body></html>'
72-
assert r.headers['Content-Type'] == 'text/html; charset=UTF-8'
73-
74-
def test_json_bom_response(self):
75-
"""the text_response_server sends the given JSON with UTF-8 BOM"""
76-
server = Server.text_response_server(
77-
"HTTP/1.1 200 OK\r\n" +
78-
"Content-Type: application/json; charset=utf-8\r\n" +
79-
u'\r\n\ufeff{"success": true}'
80-
)
81-
82-
with server as (host, port):
83-
r = requests.get('http://{}:{}'.format(host, port))
84-
85-
assert r.status_code == 200
86-
assert r.json() == {'success': True}
87-
assert r.headers['Content-Type'] == 'application/json; charset=utf-8'
88-
8959
def test_basic_response(self):
9060
"""the basic response server returns an empty http response"""
9161
with Server.basic_response_server() as (host, port):

tests/test_utils.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ def test_bad_utf_like_encoding(self):
333333

334334
@pytest.mark.parametrize(
335335
('encoding', 'expected'), (
336-
('utf-8-sig', 'utf-8-sig'),
337336
('utf-16-be', 'utf-16'),
338337
('utf-16-le', 'utf-16'),
339338
('utf-32-be', 'utf-32'),

0 commit comments

Comments
 (0)