comparison mercurial/keepalive.py @ 22958:bb7a911b138e

util: move md5 back next to sha1 and allow to call it without an argument This effectively backs out changeset 908c5906091b. The API change is done so that both util.sha1 and util.md5 can be called the same way. The function is moved in order to use it for md5 checksumming for an upcoming bundle2 feature.
author Mike Hommey <mh@glandium.org>
date Wed, 24 Sep 2014 16:00:47 +0900
parents 232d437af120
children 328739ea70c3
comparison
equal deleted inserted replaced
22957:11855ba3904c 22958:bb7a911b138e
17 17
18 # Modified by Benoit Boissinot: 18 # Modified by Benoit Boissinot:
19 # - fix for digest auth (inspired from urllib2.py @ Python v2.4) 19 # - fix for digest auth (inspired from urllib2.py @ Python v2.4)
20 # Modified by Dirkjan Ochtman: 20 # Modified by Dirkjan Ochtman:
21 # - import md5 function from a local util module 21 # - import md5 function from a local util module
22 # Modified by Martin Geisler:
23 # - moved md5 function from local util module to this module
24 # Modified by Augie Fackler: 22 # Modified by Augie Fackler:
25 # - add safesend method and use it to prevent broken pipe errors 23 # - add safesend method and use it to prevent broken pipe errors
26 # on large POST requests 24 # on large POST requests
27 25
28 """An HTTP handler for urllib2 that supports HTTP 1.1 and keepalive. 26 """An HTTP handler for urllib2 that supports HTTP 1.1 and keepalive.
615 HANDLE_ERRORS = orig 613 HANDLE_ERRORS = orig
616 hosts = keepalive_handler.open_connections() 614 hosts = keepalive_handler.open_connections()
617 print "open connections:", hosts 615 print "open connections:", hosts
618 keepalive_handler.close_all() 616 keepalive_handler.close_all()
619 617
620 def md5(s):
621 try:
622 from hashlib import md5 as _md5
623 except ImportError:
624 from md5 import md5 as _md5
625 global md5
626 md5 = _md5
627 return _md5(s)
628
629 def continuity(url): 618 def continuity(url):
619 from util import md5
630 format = '%25s: %s' 620 format = '%25s: %s'
631 621
632 # first fetch the file with the normal http handler 622 # first fetch the file with the normal http handler
633 opener = urllib2.build_opener() 623 opener = urllib2.build_opener()
634 urllib2.install_opener(opener) 624 urllib2.install_opener(opener)