mirror of
https://github.com/golang/go.git
synced 2025-11-06 19:51:00 +00:00
another attempt at utf-8 uploads.
the last attempt broke uploads of binary files like .png R=r http://go/go-review/1026025
This commit is contained in:
parent
2a63f5df98
commit
aa2a9e4796
1 changed files with 7 additions and 7 deletions
|
|
@ -2137,14 +2137,14 @@ def EncodeMultipartFormData(fields, files):
|
|||
lines.append('--' + BOUNDARY)
|
||||
lines.append('Content-Disposition: form-data; name="%s"' % key)
|
||||
lines.append('')
|
||||
if type(value) == str:
|
||||
value = value.decode("utf-8")
|
||||
if type(value) == unicode:
|
||||
value = value.encode("utf-8")
|
||||
lines.append(value)
|
||||
for (key, filename, value) in files:
|
||||
if type(filename) == str:
|
||||
filename = filename.decode("utf-8")
|
||||
if type(value) == str:
|
||||
value = value.decode("utf-8")
|
||||
if type(filename) == unicode:
|
||||
filename = filename.encode("utf-8")
|
||||
if type(value) == unicode:
|
||||
value = value.encode("utf-8")
|
||||
lines.append('--' + BOUNDARY)
|
||||
lines.append('Content-Disposition: form-data; name="%s"; filename="%s"' %
|
||||
(key, filename))
|
||||
|
|
@ -2155,7 +2155,7 @@ def EncodeMultipartFormData(fields, files):
|
|||
lines.append('')
|
||||
body = CRLF.join(lines)
|
||||
content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
|
||||
return content_type, body.encode("utf-8")
|
||||
return content_type, body
|
||||
|
||||
|
||||
def GetContentType(filename):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue