| 導航:起始頁 > Dive Into Python > HTTP Web 服務 > 調試 HTTP web 服務 | << >> | ||||
深入 Python :Dive Into Python 中文版Python 從新手到專家 [Dip_5.4b_CPyUG_Release] |
|||||
首先,讓我們開啟 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 >> |