Skip to content

Commit

Permalink
Response content_length uses encoded self.response pallets#705
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpantyukhin committed Aug 13, 2016
1 parent da16933 commit 17c8eb5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/test_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,11 @@ def generate_items():
assert resp.response == ['foo', 'bar', 'baz']


def test_response_content_length_uses_encode():
r = wrappers.Response(u'你好')
assert r.calculate_content_length() == 6


def test_form_data_ordering():
class MyRequest(wrappers.Request):
parameter_storage_class = ImmutableOrderedMultiDict
Expand Down
2 changes: 1 addition & 1 deletion werkzeug/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ def calculate_content_length(self):
self._ensure_sequence()
except RuntimeError:
return None
return sum(len(x) for x in self.response)
return sum(len(x) for x in self.iter_encoded())

def _ensure_sequence(self, mutable=False):
"""This method can be called by methods that need a sequence. If
Expand Down

0 comments on commit 17c8eb5

Please sign in to comment.