Bugs item #1647037, was opened at 2007-01-29 12:31
Message generated for change (Comment added) made by tools-sts
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1647037&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
>Status: Closed
Resolution: None
Priority: 5
Private: No
Submitted By: STS (tools-sts)
Assigned to: Nobody/Anonymous (nobody)
Summary: cookielib.CookieJar does not handle cookies when port in url

Initial Comment:
In Python 2.5 the cookielib.CookieJar does not handle cookies (i.e., recognise 
the Set-Cookie: header) when the port is specified in the URL.

e.g., 
import urllib2, cookielib
cookiejar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
# add proxy to view results
proxy_handler = urllib2.ProxyHandler({'http':'127.0.0.1:8080'})
opener.add_handler(proxy_handler)
# Install opener globally so it can be used with urllib2.
urllib2.install_opener(opener)
# The ':80' will cause the CookieJar to never handle the 
# cookie set by Google
request = urllib2.Request('http://www.google.com.au:80/')
response = opener.open(request)
response = opener.open(request) # No Cookie:
# But this works
request = urllib2.Request('http://www.google.com.au/')
response = opener.open(request)
response = opener.open(request)# Cookie: PREF=ID=d2de0..

----------------------------------------------------------------------

>Comment By: STS (tools-sts)
Date: 2007-02-01 12:10

Message:
Logged In: YES 
user_id=1693551
Originator: YES

You're right! I will close this now...Sorry about that. Also, thanks for
the logging/DEBUG code this will be very useful going forward.

----------------------------------------------------------------------

Comment By: John J Lee (jjlee)
Date: 2007-02-01 00:17

Message:
Logged In: YES 
user_id=261020
Originator: NO

This is not a bug.  If you turn on cookielib logging (see below), you'll
see that Google sends back a cookie for google.com (not .com.au) on the
first request iff you add the port number.  That cookie should not be sent
back to the server.  My copy of Firefox 1.5.0.9 doesn't send back a cookie
here either.

(note they do send a .com.au cookie when you do a search, presumably
because the search button lands you at a URL without the :80 on the end. 
It's probably just a minor oversight or an optimisation that they don't
send the .com.au cookie when you include the :80)

To turn on logging:

import sys, logging
logger = logging.getLogger("cookielib")
logger.addHandler(logging.StreamHandler(sys.stdout))
logger.setLevel(logging.DEBUG)


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1647037&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to