diff --git a/pmca/installer/__init__.py b/pmca/installer/__init__.py index d26716e..3d8b78a 100644 --- a/pmca/installer/__init__.py +++ b/pmca/installer/__init__.py @@ -15,7 +15,7 @@ Result = namedtuple('Result', 'code, message') def _buildRequest(endpoint, contentType, data): - return b'POST %s REST/1.0\r\nContent-type: %s\r\n\r\n%s' % (endpoint.encode('latin1'), contentType.encode('latin1'), data) + return b'POST ' + endpoint.encode('latin1') + b' REST/1.0\r\nContent-type: ' + contentType.encode('latin1') + b'\r\n\r\n' + data def _parseHttp(data): headers, data = data.split(b'\r\n\r\n')[:2] diff --git a/pmca/util/http.py b/pmca/util/http.py index 70d35fd..9eb23fe 100644 --- a/pmca/util/http.py +++ b/pmca/util/http.py @@ -24,11 +24,11 @@ def postFile(url, fileName, fileData, fieldName='', headers={}, cookies={}, auth boundary = ''.join(random.choice('-_' + string.digits + string.ascii_letters) for _ in range(40)) headers['Content-type'] = 'multipart/form-data; boundary=%s' % boundary data = b'\r\n'.join([ - b'--%s' % boundary.encode('latin1'), - b'Content-Disposition: form-data; name="%s"; filename="%s"' % (fieldName.encode('latin1'), fileName.encode('latin1')), + b'--' + boundary.encode('latin1'), + b'Content-Disposition: form-data; name="' + fieldName.encode('latin1') + b'"; filename="' + fileName.encode('latin1') + b'"', b'', fileData, - b'--%s--' % boundary.encode('latin1'), + b'--' + boundary.encode('latin1') + b'--', b'', ]) return request(url, data, headers, cookies, auth)