Mercurial > hg
comparison mercurial/keepalive.py @ 8296:908c5906091b
util: remove md5
This hash function is broken and should not be used by new code. It is
currently only used by keepalive.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Mon, 04 May 2009 21:30:39 +0200 |
parents | 655c435efe92 |
children | 430e59ff3437 |
comparison
equal
deleted
inserted
replaced
8295:1ea7e7d90007 | 8296:908c5906091b |
---|---|
19 | 19 |
20 # Modified by Benoit Boissinot: | 20 # Modified by Benoit Boissinot: |
21 # - fix for digest auth (inspired from urllib2.py @ Python v2.4) | 21 # - fix for digest auth (inspired from urllib2.py @ Python v2.4) |
22 # Modified by Dirkjan Ochtman: | 22 # Modified by Dirkjan Ochtman: |
23 # - import md5 function from a local util module | 23 # - import md5 function from a local util module |
24 # Modified by Martin Geisler: | |
25 # - moved md5 function from local util module to this module | |
24 | 26 |
25 """An HTTP handler for urllib2 that supports HTTP 1.1 and keepalive. | 27 """An HTTP handler for urllib2 that supports HTTP 1.1 and keepalive. |
26 | 28 |
27 >>> import urllib2 | 29 >>> import urllib2 |
28 >>> from keepalive import HTTPHandler | 30 >>> from keepalive import HTTPHandler |
526 HANDLE_ERRORS = orig | 528 HANDLE_ERRORS = orig |
527 hosts = keepalive_handler.open_connections() | 529 hosts = keepalive_handler.open_connections() |
528 print "open connections:", hosts | 530 print "open connections:", hosts |
529 keepalive_handler.close_all() | 531 keepalive_handler.close_all() |
530 | 532 |
533 def md5(s): | |
534 try: | |
535 from hashlib import md5 as _md5 | |
536 except ImportError: | |
537 from md5 import md5 as _md5 | |
538 global md5 | |
539 md5 = _md5 | |
540 return _md5(s) | |
541 | |
531 def continuity(url): | 542 def continuity(url): |
532 from util import md5 | |
533 format = '%25s: %s' | 543 format = '%25s: %s' |
534 | 544 |
535 # first fetch the file with the normal http handler | 545 # first fetch the file with the normal http handler |
536 opener = urllib2.build_opener() | 546 opener = urllib2.build_opener() |
537 urllib2.install_opener(opener) | 547 urllib2.install_opener(opener) |