December 9th, 2004, 01:47 PM
urllib2 and Keep-Alive
I'm trying to automate a form submission. But it seems that after a few tries by the script to get on the page (3 actually), I get error 302 infinite redirect on every following attempt. After sniffing the traffic, the only difference that I can detect is that Python is issuing a Connection: close header instead of using keep-alive. I think maybe the server is denying access since multiple connections are being opened.
I haven't been able to figure out how to get keep-alive working. Some things I have read say that it is supported, but I'm not sure. Just setting the header doesn't seem to work (it gets over-ridden by a Connection: close). And if it is supported, is it supported in conjuction with cookielib? I'm using Python 2.4 so cookielib has ClientCookie builtin. Any thoughts would be greatly appreciated!