2012-03-12 127 views
2

如何在python框架瓶中获取整个原始http请求?打印出整个原始http请求

我需要的是这样的:

GET\n 
myurl.com\n 
/\n 
attribute=value 
&att2=value2 

我需要这让我签字HTTP API请求

回答

3

据我可以从​​告诉你不能在原始格式获取数据。

你可以做的是使用bottle.request.databottle.request.headers重建它。这对你的目的可能已经足够了。

+0

bottle.request.method和bottle.request.query是我的解决方案的感谢! – tuna 2012-03-12 20:53:55

2

如果你只是想打印的要求,您可以执行以下操作:

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)))