grabbing a cookie
Jose Isaias Cabrera
jicman at cinops.xerox.com
Mon Oct 2 12:35:22 EDT 2000
Hi all!
Using
import httplib
I did a POST to a server to login to it with the following http connection:
h = httplib.HTTP(host,port)
I used the code
reply, msg, hdrs = h.getreply()
to get the reply, the message and the headers (duh!). In the headers (hdrs), I have a cookie returned with a header "Set-Cookie". I could print the header (hdrs) to STDOUT, by using
print hdrs
and I get
Date: Mon, 02 Oct 2000 16:21:07 GMT
Server: Apache/1.3.0 (Unix)
Set-Cookie: AmberUser=%b7%07%0eS%cbm%8f%3b%9b%88%27%2a%1c%d3%ed%b000080%981%a7%e6%02%10%bf; path=/
Connection: close
Content-Type: text/xml
but I can not get the content of the cookie into a variable because I can't not search through it or anything. If I use the line,
for x in hdrs:
print x
it gives me the error
Traceback (innermost last):
File "C:\MYPROG~1\MyHTTP.py", line 93, in ?
Cookie = gologin(loginID,password)
File "C:\MYPROG~1\MyHTTP.py", line 70, in gologin
for x in hdrs:
File "d:\Program Files\Python\Lib\rfc822.py", line 356, in __getitem__
return self.dict[string.lower(name)]
TypeError: read-only character buffer, int
So, the question is, how can I get the cookie into a variable that I can use to sent to that server? Or how can I read this information given back by the server in some kind of bin-hex mode?
thanks for your help,
jose
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20001002/27b3556f/attachment.html>
More information about the Python-list
mailing list