您当前位置: 首页 > 深入 Python > HTTP Web 服务 > 调试 HTTP Web 服务 | << >> | ||||
深入 Python从 Python 新手到专家 |
首先,让我们启用 Python HTTP 库的调试功能,看看通过网络发送了什么。这在本章中非常有用,因为您将添加越来越多的功能。
>>> import httplib >>> httplib.HTTPConnection.debuglevel = 1>>> import urllib >>> feeddata = urllib.urlopen('http://diveintomark.org/xml/atom.xml').read() connect: (diveintomark.org, 80)
send: ' GET /xml/atom.xml HTTP/1.0
Host: diveintomark.org
User-agent: Python-urllib/1.15
' reply: 'HTTP/1.1 200 OK\r\n'
header: Date: Wed, 14 Apr 2004 22:27:30 GMT header: Server: Apache/2.0.49 (Debian GNU/Linux) header: Content-Type: application/atom+xml header: Last-Modified: Wed, 14 Apr 2004 22:14:38 GMT
header: ETag: "e8284-68e0-4de30f80"
header: Accept-Ranges: bytes header: Content-Length: 26848 header: Connection: close
<< HTTP 的功能 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
设置 User-Agent >> |