Patches item #1755841, was opened at 2007-07-18 08:02 Message generated for change (Comment added) made by orsenthil You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1755841&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: Library (Lib) Group: Python 2.6 Status: Open Resolution: None Priority: 5 Private: No Submitted By: O.R.Senthil Kumaran (orsenthil) Assigned to: Nobody/Anonymous (nobody) Summary: Patch for [ 735515 ] urllib2 should cache 301 redir Initial Comment: Tracker item python.org/sf/735515 mentions about urllib2 to cache 301 redirections. Attached patch tries to implement the same. Comments on Version 1 of patch: a) Initializes a dictionary to store the redirection. b) If req already in cache, return the previous Request object. c) Otherwise handle the same as 302 and store the Request object. d) Checks for loop errors in 301. Just noticed, that it I missed max-redirect checks. Please comment on this patch, with next version I shall add the max redirect check. ---------------------------------------------------------------------- >Comment By: O.R.Senthil Kumaran (orsenthil) Date: 2007-08-06 02:29 Message: Logged In: YES user_id=942711 Originator: YES Hi Skip, Added the updated patch and also added patches to test and documentation also. Did some investigation on Cache redirection and expires for 302. IMHO, it should be handled as a separate feature request (based on the need), as we will have to handle the Cache-Control header values in addition to expires header. This would amount for good amount of change w.r.t the HTTPRedirectHandler itself. [http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html section 14.9] As for the current Tracker item, please verify and if found suitable checkin to the Python trunk. Thanks, Senthil ---------------------------------------------------------------------- Comment By: O.R.Senthil Kumaran (orsenthil) Date: 2007-08-06 02:13 Message: Logged In: YES user_id=942711 Originator: YES File Added: liburllib2.patch ---------------------------------------------------------------------- Comment By: O.R.Senthil Kumaran (orsenthil) Date: 2007-08-06 02:12 Message: Logged In: YES user_id=942711 Originator: YES File Added: test_urllib2-cache.patch ---------------------------------------------------------------------- Comment By: O.R.Senthil Kumaran (orsenthil) Date: 2007-08-06 02:11 Message: Logged In: YES user_id=942711 Originator: YES File Added: urllib2-301-cache.patch ---------------------------------------------------------------------- Comment By: Skip Montanaro (montanaro) Date: 2007-08-02 16:25 Message: Logged In: YES user_id=44345 Originator: NO How much extra work would it be to handle 302 redirects and the Expiry header? (I don't want to hold you up from the rest of your SoC tasks. Time's running out.) Note also that you should also include a patch to the urllib2 documentation and, if possible, one or more test cases to exercise the new code. Skip ---------------------------------------------------------------------- Comment By: O.R.Senthil Kumaran (orsenthil) Date: 2007-08-02 09:47 Message: Logged In: YES user_id=942711 Originator: YES Hi Skip, I have implemented Cache redirection for 301 errors only which will be Permanant redirection. Expiry header is not expected for 301 direction, so we might not purge it. RFC 2616 states that if cache is implemented for 302 redirects ( temporary redirects) than Expiry header should be handled and cache purged. For our change it is not required. Thanks, Senthil ---------------------------------------------------------------------- Comment By: Skip Montanaro (montanaro) Date: 2007-07-26 20:08 Message: Logged In: YES user_id=44345 Originator: NO Looks reasonable to me, however I wonder if you shouldn't purge cached information periodically. Does RFC 2616 provide any guidance? Skip ---------------------------------------------------------------------- Comment By: O.R.Senthil Kumaran (orsenthil) Date: 2007-07-24 09:26 Message: Logged In: YES user_id=942711 Originator: YES I have made some changes to patch. Made it use just the self.cache to cache and follow the same logic for redirect and loop as 302 would follow. I thought this is ok. Did a basic testing to verify if it caught 301 redirect, yes it does. File Added: urllib2-cache-301.patch ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1755841&group_id=5470 _______________________________________________ Patches mailing list Patches@python.org http://mail.python.org/mailman/listinfo/patches