summaryrefslogtreecommitdiff
path: root/demo/ssl/http_cli_20.py
blob: 0ce4cefd9dbb9dc6f2c222df3a91e4fdaf7338a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import httplib, sys

def test_httplib():
    h = httplib.HTTPConnection('127.0.0.1', 80)
    h.set_debuglevel(1)
    h.putrequest('GET', '/')
    h.putheader('Accept', 'text/html')
    h.putheader('Accept', 'text/plain')
    h.putheader('Connection', 'close')
    h.endheaders()
    resp = h.getresponse()
    f = resp.fp
    while 1:
        data = f.readline()   
        if not data:
            break
        sys.stdout.write(data)
    f.close()
    h.close()

if __name__=='__main__':
    test_httplib()