Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 打印出整个原始http请求_Python_Http_Request_Hmac_Bottle - Fatal编程技术网

Python 打印出整个原始http请求

Python 打印出整个原始http请求,python,http,request,hmac,bottle,Python,Http,Request,Hmac,Bottle,如何在python框架中获得整个原始http请求 我需要这样的东西: GET\n myurl.com\n /\n attribute=value &att2=value2 我需要这个来签署我的http api请求据我所知,您无法以原始格式获取数据 您所能做的就是使用瓶状物.request.data和瓶状物.request.headers重新构建它。就您的目的而言,这可能就足够了。如果您只想打印请求,可以执行以下操作: headers_string = ['{}: {}'.format(

如何在python框架中获得整个原始http请求

我需要这样的东西:

GET\n
myurl.com\n
/\n
attribute=value
&att2=value2
我需要这个来签署我的http api请求

据我所知,您无法以原始格式获取数据


您所能做的就是使用
瓶状物.request.data
瓶状物.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)))

瓶子.request.method和瓶子.request.query是我的解决方案,谢谢!