import urllib.request, urllib.error, urllib.parse
data = 'binary-data'
r = urllib.request.Request('http://example.net/put', data, {'Content-Type':
    'application/octet-stream'})
r.get_method = lambda : 'PUT'
python: HTTP PUT with unencoded binary data