[英]Print out the whole raw http request
如何在python框架瓶中獲取整個原始的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)))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.