ClientCookie bug (followup)

Mark Carter cartermark46 at ukmail.com
Mon Aug 18 16:05:06 CEST 2003


> I'll investigate further. 

Here are the results from running tests in ClientCookie 0.4.4.a:

def go7():
    #ClientCookie 0.4.4.a:
    #works from win xp and win 98
    
    # I prefer this method as a better way than using
load_from_registry()
    #use this method!!

    import ClientCookie
    c = ClientCookie.MSIECookieJar() # do NOT set delayload
    #c.user_name = "mark carter"
    c.load_cookie_data("hemscott-cookie.bin")
    #c.load_from_registry()
    print c

    import urllib2
    url = 'http://businessplus.hemscott.net/corp/crp03733.htm'
    request = urllib2.Request(url)
    response = urllib2.urlopen(request)
    c.extract_cookies(response, request)
    #let's say this next request requires a cookie that was set in
response
    request2 = urllib2.Request(url)
    c.add_cookie_header(request2)
    response2 = urllib2.urlopen(request2)

    print response2.geturl()
    print response2.info()  # headers
    print response2.read()
    response2.close()



def go8():
    #ClientCookie 0.4.4.a:
    #contains bug in Win98 when environ variable is commented out,
    #but works in win98 when environ variable is set
    #Works in win xp , regardless of the USERNAME line
    
    #this works - I can now import into Hemscott	
    import ClientCookie
    c = ClientCookie.MSIECookieJar(delayload=1)
    #c.user_name = "mark carter"
    #os.environ['USERNAME'] = 'mcarter' #needed by
load_from_registry()
    c.load_from_registry()

    import urllib2
    url = 'http://businessplus.hemscott.net/corp/crp03733.htm'
    request = urllib2.Request(url)
    response = urllib2.urlopen(request)
    #c.extract_cookies(response, request)
    # let's say this next request requires a cookie that was set in
response
    request2 = urllib2.Request(url)
    c.add_cookie_header(request2)
    response2 = urllib2.urlopen(request2)

    print response2.geturl()
    print response2.info()  # headers
    for line in response2.readlines():  # body
         print line


The upshot of this is that load_cookie_data() now works in win 98 and
xp.
load_from_registry() works from win xp; it works from win 98 if and
only if you set the USERNAME environment variable.

I appreciate that all the stuff about request2 and response2 may not
be to your liking - but at the moment I'm just trying to figure out
what works, and what doesn't. We can also worry about the delayload
business later.

What do you think about the idea of actually setting up an Aapache web
page to test these things 'for real'?




More information about the Python-list mailing list