Passing a Cookie with httplib

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Thu Jun 29 05:42:50 EDT 2006


In article <i2o5a25a06v8plrbj4m76d67m90g2vn0ps at 4ax.com>,
 scott at bogusaddress.com wrote:

>I would like to
>hard code the cookie in the code so it works every time:   
>
>i.e. cookie = 'auth=buster%3A12345678901234567890exZ9rzMqgtxa5A'.  
>
>    conn=httplib.HTTPConnection(WP_SERVER)
>    conn.request('GET',WP_PATH % uservalue)    

According to <http://docs.python.org/lib/httpconnection-objects.html>, 
you can pass additional "body" and "headers" args to 
HTTPConnection.request. How about trying something like this in place of 
the last line above:

    Headers = {"Cookie" : 
"auth=buster%3A12345678901234567890exZ9rzMqgtxa5A"}
    conn.request('GET',WP_PATH % uservalue, None, Headers)



More information about the Python-list mailing list