Loading file contents using 'r' does not work in Python 3
and results in an encoding error. Replaced with 'rb'.
Fix2: Be more robust when MIME types are detected:
Treat 'application/x-gzip' as 'application/gzip'.
(This will also allow to use osmclient on OS X)
Change-Id: I430b2fae2c275803120a6815d01bb26bff26ebdc
Signed-off-by: peusterm <manuel.peuster@upb.de>
(pycurl.FORM_FILE,
formfile[1])))])
elif filename is not None:
- with open(filename, 'r') as stream:
+ with open(filename, 'rb') as stream:
postdata=stream.read()
curl_cmd.setopt(pycurl.POSTFIELDS, postdata)
headers= self._client._headers
if mime_type in ['application/yaml', 'text/plain']:
headers['Content-Type'] = 'application/yaml'
- elif mime_type == 'application/gzip':
+ elif mime_type in ['application/gzip', 'application/x-gzip']:
headers['Content-Type'] = 'application/gzip'
#headers['Content-Type'] = 'application/binary'
# Next three lines are to be removed in next version
headers= self._client._headers
if mime_type in ['application/yaml', 'text/plain']:
headers['Content-Type'] = 'application/yaml'
- elif mime_type == 'application/gzip':
+ elif mime_type in ['application/gzip', 'application/x-gzip']:
headers['Content-Type'] = 'application/gzip'
#headers['Content-Type'] = 'application/binary'
# Next three lines are to be removed in next version