get-with-headers: fix stream modes under Windows stable
authorPatrick Mezard <pmezard@gmail.com>
Sun, 28 Sep 2008 20:40:38 +0200
branchstable
changeset 515 9ea5ac3258b6
parent 514 06b69a53ab0f
child 516 0107b6de1a35
child 518 55b462bc9343
get-with-headers: fix stream modes under Windows [ original upstream descripton ]
tests/get-with-headers.py
--- a/tests/get-with-headers.py	Wed Nov 28 08:38:42 2007 -0800
+++ b/tests/get-with-headers.py	Sun Sep 28 20:40:38 2008 +0200
@@ -4,6 +4,14 @@
 a subset of the headers plus the body of the result."""
 
 import httplib, sys
+
+try:
+    import msvcrt, os
+    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
+    msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
+except ImportError:
+    pass
+
 headers = [h.lower() for h in sys.argv[3:]]
 conn = httplib.HTTPConnection(sys.argv[1])
 conn.request("GET", sys.argv[2])