(url)
| 517 | keepalive_handler.close_all() |
| 518 | |
| 519 | def continuity(url): |
| 520 | from hashlib import md5 |
| 521 | format = '%25s: %s' |
| 522 | |
| 523 | # first fetch the file with the normal http handler |
| 524 | opener = _urllib.request.build_opener() |
| 525 | _urllib.request.install_opener(opener) |
| 526 | fo = _urllib.request.urlopen(url) |
| 527 | foo = fo.read() |
| 528 | fo.close() |
| 529 | m = md5(foo) |
| 530 | print(format % ('normal urllib', m.hexdigest())) |
| 531 | |
| 532 | # now install the keepalive handler and try again |
| 533 | opener = _urllib.request.build_opener(HTTPHandler()) |
| 534 | _urllib.request.install_opener(opener) |
| 535 | |
| 536 | fo = _urllib.request.urlopen(url) |
| 537 | foo = fo.read() |
| 538 | fo.close() |
| 539 | m = md5(foo) |
| 540 | print(format % ('keepalive read', m.hexdigest())) |
| 541 | |
| 542 | fo = _urllib.request.urlopen(url) |
| 543 | foo = '' |
| 544 | while 1: |
| 545 | f = fo.readline() |
| 546 | if f: foo = foo + f |
| 547 | else: break |
| 548 | fo.close() |
| 549 | m = md5(foo) |
| 550 | print(format % ('keepalive readline', m.hexdigest())) |
| 551 | |
| 552 | def comp(N, url): |
| 553 | print(' making %i connections to:\n %s' % (N, url)) |
no test coverage detected
searching dependent graphs…