New submission from Jon Debonis <j...@tooln.com>:

Added ability to insert cookies into cookie jar.

Fixed problem where some domain names are prepended with '.' and others 
were not.

Fixed problem with _LWPCookieJar.py to handle case where version = None

----
import urllib2, urllib, time
import cookielib
            
req_url = 'http://google.com'

## OPEN COOKIE JAR - Optional
cj = cookielib.CookieJar()

cookie_handler = urllib2.HTTPCookieProcessor(cj)
opener = urllib2.build_opener(cookie_handler)
urllib2.install_opener(opener)

req = urllib2.Request(url=req_url)
    
cj.add_cookie(req, 'cname2', 'cval2',
                {'expires':  int(time.time()) + 3600,})

cj.add_cookie(req, 'cname3', 'cval3') 

print "-" * 45
print "Cookies before first request is sent:"
for index, cookie in enumerate(cj):
    print index, '  :  ', cookie

res = urllib2.urlopen(req)
# Google will redirect, and clear the additional cookies
print "-" * 45
print "Cookies after first request is sent:"
print "(google cleared extra cookies)"
for index, cookie in enumerate(cj):
    print index, '  :  ', cookie
---

----------
components: Library (Lib)
files: cookie_update.diff
keywords: patch
messages: 91000
nosy: jondebonis
severity: normal
status: open
title: insert cookies into cookie jar - cookielib.py
type: feature request
versions: Python 2.6
Added file: http://bugs.python.org/file14582/cookie_update.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue6588>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to