mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
fixed the test program
This commit is contained in:
parent
aad8692328
commit
a0dfc7ad65
1 changed files with 6 additions and 3 deletions
|
@ -110,21 +110,24 @@ def test():
|
||||||
dl = 0
|
dl = 0
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
if o == '-d': dl = dl + 1
|
if o == '-d': dl = dl + 1
|
||||||
host = 'www.cwi.nl:80'
|
host = 'www.python.org'
|
||||||
selector = '/index.html'
|
selector = '/'
|
||||||
if args[0:]: host = args[0]
|
if args[0:]: host = args[0]
|
||||||
if args[1:]: selector = args[1]
|
if args[1:]: selector = args[1]
|
||||||
h = HTTP()
|
h = HTTP()
|
||||||
h.set_debuglevel(dl)
|
h.set_debuglevel(dl)
|
||||||
h.connect(host)
|
h.connect(host)
|
||||||
h.putrequest('GET', selector)
|
h.putrequest('GET', selector)
|
||||||
|
h.endheaders()
|
||||||
errcode, errmsg, headers = h.getreply()
|
errcode, errmsg, headers = h.getreply()
|
||||||
print 'errcode =', errcode
|
print 'errcode =', errcode
|
||||||
print 'headers =', headers
|
|
||||||
print 'errmsg =', errmsg
|
print 'errmsg =', errmsg
|
||||||
|
print
|
||||||
if headers:
|
if headers:
|
||||||
for header in headers.headers: print string.strip(header)
|
for header in headers.headers: print string.strip(header)
|
||||||
|
print
|
||||||
print h.getfile().read()
|
print h.getfile().read()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test()
|
test()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue