Fix1: Package upload using Python3 was still broken: BUILD_v4.0.1_1 BUILD_v4.0.1_2
authorpeusterm <manuel.peuster@uni-paderborn.de>
Fri, 15 Jun 2018 12:46:23 +0000 (14:46 +0200)
committerpeusterm <manuel.peuster@uni-paderborn.de>
Fri, 15 Jun 2018 12:46:23 +0000 (14:46 +0200)
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>
osmclient/sol005/http.py
osmclient/sol005/nsd.py
osmclient/sol005/vnfd.py

index 7988d89..867db2d 100644 (file)
@@ -74,7 +74,7 @@ class Http(http.Http):
                            (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)
 
index 0dbec43..63308d6 100644 (file)
@@ -128,7 +128,7 @@ class Nsd(object):
         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
index c769d4c..b239d57 100644 (file)
@@ -127,7 +127,7 @@ class Vnfd(object):
         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