Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/atom/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,17 +723,18 @@ def CalculateDataLength(data):
data: object If this is not a string or ElementTree element this funtion
will return None.
"""
#If non-ascii is in data, Content-Length will be too short.
if isinstance(data, str):
return len(data)
return len( data.encode('utf-8') )
elif isinstance(data, list):
return None
elif ElementTree.iselement(data):
return len(ElementTree.tostring(data))
return len( ElementTree.tostring(data).encode('utf-8') )
elif hasattr(data, 'read'):
# If this is a file-like object, don't try to guess the length.
return None
else:
return len(str(data))
return len( str(data).encode('utf-8') )


def deprecation(message):
Expand Down