Skip to content

Commit

Permalink
Use utf-8 instead of ASCII encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcarl committed May 14, 2016
1 parent 2f2e57c commit 6d23079
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions imgurup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,23 +516,23 @@ def get_content_type(filename):

def encode_field(field_name):
return (
('--' + boundary).encode('ASCII'),
('--' + boundary).encode('utf-8'),
('Content-Disposition: form-data; name="%s"' % (
field_name
)).encode('ASCII'),
b'', data[field_name].encode('ASCII')
)).encode('utf-8'),
b'', data[field_name].encode('utf-8')
)

def encode_file(field_name):
filename = files[field_name]
return (
('--' + boundary).encode('ASCII'),
('--' + boundary).encode('utf-8'),
('Content-Disposition: form-data; name="%s"; filename="%s"' % (
field_name, filename
)).encode('ASCII'),
)).encode('utf-8'),
('Content-Type: %s' % (
get_content_type(filename)
)).encode('ASCII'),
)).encode('utf-8'),
b'', open(filename, 'rb').read()
)

Expand All @@ -542,8 +542,8 @@ def encode_file(field_name):
lines.extend(encode_field(name))
for name in files:
lines.extend(encode_file(name))
lines.extend((('--%s--' % boundary).encode('ASCII'), b''))
body = '\r\n'.encode('ASCII').join(lines)
lines.extend((('--%s--' % boundary).encode('utf-8'), b''))
body = '\r\n'.encode('utf-8').join(lines)

headers = {
'content-type': 'multipart/form-data; boundary=' + boundary,
Expand Down

0 comments on commit 6d23079

Please sign in to comment.