Skip to content

Commit

Permalink
Don't concat byte strings with %
Browse files Browse the repository at this point in the history
  • Loading branch information
ma1co committed Dec 28, 2016
1 parent fc78058 commit 6771fcd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pmca/installer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions pmca/util/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6771fcd

Please sign in to comment.