This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: urllib2 proxyhandle won't work.
Type: Stage:
Components: Library (Lib) Versions: Python 2.2
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: jhylton Nosy List: facundobatista, hashao, jhylton, jimjjewett, jjlee, micahs, nnorwitz, nobody
Priority: normal Keywords:

Created on 2001-11-30 12:54 by hashao, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
urllib2.diff hashao, 2001-11-30 12:54 urllib2.diff patch to build_opener
urllib2.diff2 hashao, 2001-11-30 13:10 2nd and more correct patch
Messages (9)
msg7917 - (view) Author: Ha Shao (hashao) Date: 2001-11-30 12:54
For python 2.2b2:
Adding proxyhandler with build_opener, install_opener does not
work since order of the handlers does matter (my guess).

In the current code, new handlers are appended at the end
of the handlers list. At least under windows, the proxyhandle
will never got called if it is added with install_opener.
HTTPHandler always get called before proxyhandler if the
default list is altered.

The attached patch try to reserve the order of handlers
based on their baseclass when adding new handlers.

Handlers with the same baseclasses might be added
more than once. Not sure if it is a good thing or bad
thing. Current code will raise except when it trys to remove 
the default handlers twice.

Since order does matter, build_opener
should be repleased by a list like class such that
user can insert their handlers to specific place.
msg7918 - (view) Author: Ha Shao (hashao) Date: 2001-11-30 13:10
Logged In: YES 
user_id=8717

forgot some code and changed a stupid variable name.
msg7919 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2003-01-13 21:50
Logged In: YES 
user_id=33168

Ha Shao, I know there were many changes in Python 2.2.x in
this area.  Do you still have this problem?  Can this bug be
closed?
msg7920 - (view) Author: Deleted User micahs (micahs) Date: 2003-05-07 23:29
Logged In: YES 
user_id=774014

I don't know about Ha Shao, but I have the problem with Python 2.2.2.  My work around was to
modify urllib2.build_opener to add the user's supplied handlers before the defaults.  Shao's idea
of a list-like class is probably better.
msg7921 - (view) Author: Nobody/Anonymous (nobody) Date: 2003-10-30 18:57
Logged In: NO 

This should be closed. 
 
I don't recall which minor version of 2.2 this was introduced at, 
but there's no need to replace build_opener any more.  The 
most you have to do is to explicitly pass a handler or two to 
build_opener with appropriately set handler_order attributes.  
Or you can subclass the handlers. 
msg7922 - (view) Author: John J Lee (jjlee) Date: 2003-10-30 19:02
Logged In: YES 
user_id=261020

That last comment was from me (cookie problems, ironically).
msg7923 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2004-11-25 23:58
Logged In: YES 
user_id=752496

Please, could you verify if this problem persists in Python 2.3.4
or 2.4?

If yes, in which version? Can you provide a test case?

If the problem is solved, from which version?

Note that if you fail to answer in one month, I'll close this bug
as "Won't fix".

Thank you! 

.    Facundo
msg7924 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2005-01-15 22:32
Logged In: YES 
user_id=752496

Deprecated. Reopen only if still happens in 2.3 or newer. 

.    Facundo
msg7925 - (view) Author: Jim Jewett (jimjjewett) Date: 2005-03-22 22:04
Logged In: YES 
user_id=764593

As John J. Lee said, it is fixed now.

The fix was in 1.48, which was apparently included with 
python 2.3beta2 - and therefore the problem doesn't occur.

That said, there is an XXX comment added in 1.57 asking 
# XXX why does self.handlers need to be sorted?

and if they aren't sorted, then the issue will recur in some but 
not all tests.
History
Date User Action Args
2022-04-10 16:04:42adminsetgithub: 35636
2001-11-30 12:54:30hashaocreate