2
如何在python框架瓶中获取整个原始http请求?打印出整个原始http请求
我需要的是这样的:
GET\n
myurl.com\n
/\n
attribute=value
&att2=value2
我需要这让我签字HTTP API请求
如何在python框架瓶中获取整个原始http请求?打印出整个原始http请求
我需要的是这样的:
GET\n
myurl.com\n
/\n
attribute=value
&att2=value2
我需要这让我签字HTTP API请求
据我可以从告诉你不能在原始格式获取数据。
你可以做的是使用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)))
bottle.request.method和bottle.request.query是我的解决方案的感谢! – tuna 2012-03-12 20:53:55