The HTTP library of python is very simple and easy to use for fast debugging of the C/S protocol :)
See: http://docs.python.org/release/2.6/library/httplib.html
# Coding = gbkimport httplibprint 'start... 'conn = httplib. httpconnection ('www .google.com ', 80) Conn. set_debuglevel (2) # httpconnection. request (method, URL [, body [, headers]) Conn. request ('get', '/', headers = {"host": "www.google.com", "User-Agent": "Mozilla/5.0 (windows; U; Windows NT 5.1; zh-CN; RV: 1.9.1) Gecko/20090624 Firefox/3.5 "," accept ":" text/plain "}) # Conn. getresponse (). read () Respond = Conn. getresponse () # obtain all response header information. Print 'status: ', respond. Status # obtain the HTTP protocol version used by the server. 11 indicates HTTP/1.1; 10 indicates HTTP/1.0. Print 'version: ', respond. version # obtain the response status code. For example, 200 indicates that the request is successful. Print 'reason: ', respond. Reason # returns all header information in the form of a list. Print 'msg: ', respond. MSG # returns all header information in the form of a list. Http_respond = respond. getheaders () for it in http_respond: Print itconn. Close () print 'end ...'