我有一个与此类似的代码:
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)
这非常简洁漂亮,但是请求是仅python的库,而我试图转换最后一行:
requests.get(url, headers=headers)
要与python的套接字库一起使用,希望是这样的:
s3_message= ''' respective bytestring '''.encode('utf8')
socket.send(s3_message)
我可以以某种方式从请求中获取字节串,以便使用模式吗?如果没有,是否有某种方法可以找出正确的套接字消息?