【发布时间】:2012-03-28 21:24:52
【问题描述】:
如何在 python 框架瓶中获取整个原始 http 请求?
我需要这样的东西:
GET\n
myurl.com\n
/\n
attribute=value
&att2=value2
我需要这个来签署我的 http api 请求
【问题讨论】:
标签: python http request hmac bottle
如何在 python 框架瓶中获取整个原始 http 请求?
我需要这样的东西:
GET\n
myurl.com\n
/\n
attribute=value
&att2=value2
我需要这个来签署我的 http api 请求
【问题讨论】:
标签: python http request hmac bottle
据我从the docs 得知,您无法获取原始格式的数据。
您可以使用bottle.request.data 和bottle.request.headers 重建它。这对于您的目的可能已经足够了。
【讨论】:
如果您只想打印请求,您可以执行以下操作:
headers_string = ['{}: {}'.format(h, request.headers.get(h)) for h in request.headers.keys()]
print('URL={}, method={}\nheaders:\n{}'.format(request.url, request.method, '\n'.join(headers_string)))
【讨论】: