Seems that urllib2 sends HTTP/1.1 request by default?
To avoid monkey-patching httplib (global change), you could subclass HTTPConnection and define your own http handler:
#!/usr/bin/env python
try:
from httplib import HTTPConnection
from urllib2 import HTTPHandler, build_opener
except ImportError: # Python 3
from http.client import HTTPConnection
from urllib.request import HTTPHandler, build_opener
class HTTP10Connection(HTTPConnection):
_http_vsn = 10
_http_vsn_str = "HTTP/1.0"
class HTTP10Handler(HTTPHandler):
def http_open(self, req):
return self.do_open(HTTP10Connection, req)
opener = build_opener(HTTP10Handler)
print(opener.open('http://stackoverflow.com/q/13656757').read()[:100])