comparison tests/get-with-headers.py @ 7054:e837f2294643

get-with-headers: fix stream modes under Windows
author Patrick Mezard <pmezard@gmail.com>
date Sun, 28 Sep 2008 20:40:38 +0200
parents 22713dce19f6
children c5e37dc38a52
comparison
equal deleted inserted replaced
7053:209ef5f3534c 7054:e837f2294643
2 2
3 __doc__ = """This does HTTP get requests given a host:port and path and returns 3 __doc__ = """This does HTTP get requests given a host:port and path and returns
4 a subset of the headers plus the body of the result.""" 4 a subset of the headers plus the body of the result."""
5 5
6 import httplib, sys 6 import httplib, sys
7
8 try:
9 import msvcrt, os
10 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
11 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
12 except ImportError:
13 pass
14
7 headers = [h.lower() for h in sys.argv[3:]] 15 headers = [h.lower() for h in sys.argv[3:]]
8 conn = httplib.HTTPConnection(sys.argv[1]) 16 conn = httplib.HTTPConnection(sys.argv[1])
9 conn.request("GET", sys.argv[2]) 17 conn.request("GET", sys.argv[2])
10 response = conn.getresponse() 18 response = conn.getresponse()
11 print response.status, response.reason 19 print response.status, response.reason