I have a code akin to this:
import requests
endpoint = 'https://s3.amazonaws.com'
host = 's3.amazonaws.com'
bucket = 'mybucket'
key = 'mykey'
access_key = 'access'
secret_key = 'secret'
url = '/'.join([endpoint, bucket, key])
headers = {'Host': host, 'User-Agent': 'whatever'}
headers = get_more_amazon_headers(headers, host, bucket, key, access_key, secret_key)
requests.get(url, headers=headers)
This is very terse and nice, but requests is a python only library, and I was trying to convert the last line:
requests.get(url, headers=headers)
to be used with python's socket library, hopefully something like:
s3_message= ''' respective bytestring '''.encode('utf8')
socket.send(s3_message)
Can I somehow get the bytestring out of requests, so I can use the pattern? If not, is there some way to figure out the correct socket message?