I'm trying to use HTTPConnection (2.7.8) to make a request and I've set the timeout to 10 with HTTPConnection(host, timeout=10). However, HTTPConnection.request() doesn't seem to timeout after 10 seconds. In fact, HTTPConnection.timeout doesn't even seem to be read by HTTPConnection.request() (it's only read by HTTPConnection.connect(). Is my understanding correct? Is timeout only applicable to connect() and not request()? Is there a way to timeout request()?
Update:
I think I've narrowed the issue down further: if I don't provide the scheme, it won't respect the socket timeout. If the scheme was provided, i.e. the full URL being http://google.com:22222, then it'd time out accordingly. I wonder why the presence of the scheme should make a difference. That is, the following doesn't respect the timeout
socket.setdefaulttimeout(3)
conn = HTTPConnection('google.com:22222')
conn.timeout = 3
conn.request('GET', '')
whereas, this does:
socket.setdefaulttimeout(3)
conn = HTTPConnection('http://google.com:22222')
conn.timeout = 3
conn.request('GET', '')
However, it doesn't happen to all domains.
Thanks