• Jeremy Hylton's avatar
    SF patch 852995: add processors feature to urllib2 · c1be59f4
    Jeremy Hylton yazdı
    John J. Lee writes: "the patch makes it possible to implement
    functionality like HTTP cookie handling, Refresh handling,
    etc. etc. using handler objects. At the moment urllib2's handler
    objects aren't quite up to the job, which results in a lot of
    cut-n-paste and subclassing. I believe the changes are
    backwards-compatible, with the exception of people who've
    reimplemented build_opener()'s functionality -- those people would
    need to call opener.add_handler(HTTPErrorProcessor).
    
    The main change is allowing handlers to implement
    methods like:
    
    http_request(request)
    http_response(request, response)
    
    In addition to the usual
    
    http_open(request)
    http_error{_*}(...)
    "
    
    Note that the change isn't well documented at least in part because
    handlers aren't well documented at all.  Need to fix this.
    
    Add a bunch of new tests.  It appears that none of these tests
    actually use the network, so they don't need to be guarded by a
    resource flag.
    c1be59f4
liburllib2.tex 24.9 KB