httplib2可以获得原始响应头

时间:2014-10-07 15:44:24

标签: python python-2.7 http-headers httplib2

以下是我的示例代码:

http.debuglevel=1
...
response, content = conn.request(target,method,body,headers)
print response

这是我在调试中的结果(注意我刚刚在这里留下几行)

reply: 'HTTP/1.1 200 OK\r\n'
header: Pragma: no-cache
header: Content-Type: application/octet-stream
header: Content-Encoding: gzip
header: Content-Length: 18480
...
...

这是print.response结果(注意我刚刚在这里留下几行)

{
'status': '200',
'content-length': '55559',
'-content-encoding': 'gzip',
'pragma': 'no-cache',
'content-type': 'application/octet-stream'
 ...
 ...
}

所以我的问题是:

  1. 调试显示gzip压缩内容的实际内容长度。如何获得原始内容长度?
  2. 在调试'内容编码'似乎是正确的。在httplib2.response中,它是'-content-encoding'。为什么?
  3. 是否有任何方法可以访问调试输出显示的响应头?

0 个答案:

没有答案
相关问题