Simple httplib problem

Afanasiy abelikov72 at hotmail.com
Mon Jan 6 18:57:46 EST 2003


Can someone tell me what I am doing wrong here?

I need to get a file via http, but must login first, so I am doing two
requests. The login request succeeds and I get the correct HTML
response. But the second request to get the actual file I wanted (after
logging in) is throwing an httplib.ResponseNotReady exception.

I've replaced >>> with --- to avoid confusion with quoted text.

---h = httplib.HTTPConnection('123.45.67.89')
---h.connect()
---h.putrequest('GET','/default.asp?loginname=myuser&password=mypass&action=login')
---h.putheader('Accept','text/html')
---h.putheader('Accept','text/plain')
---h.endheaders()
---h.send('')
---r = h.getresponse()
---r.status
200
---r.getheader('Set-Cookie')
'ASPSESSIONIDGQGGHQKY=OFIPJJMABHNODAIFKFPDPMCN; path=/'
---cookie = r.getheader('Set-Cookie')
---h.putrequest('GET','/secure.asp')
---h.putheader('Cookie',cookie)
---h.putheader('Set-Cookie',cookie)
---h.putheader('Accept','text/html')
---h.putheader('Accept','text/plain')
---h.endheaders()
---h.send('')
---r2 = h.getresponse()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Python22\lib\httplib.py", line 752, in getresponse
    raise ResponseNotReady()
httplib.ResponseNotReady




More information about the Python-list mailing list