Mercurial > hg
comparison mercurial/url.py @ 51827:ace0da86edd0
urllib2: redo response.readlines addition via class patching
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Fri, 28 Jun 2024 16:26:06 +0200 |
parents | d718eddf01d9 |
children | b08de326bee4 |
comparison
equal
deleted
inserted
replaced
51826:0338fb200a30 | 51827:ace0da86edd0 |
---|---|
497 self.cookiejar.add_cookie_header(request) | 497 self.cookiejar.add_cookie_header(request) |
498 | 498 |
499 return request | 499 return request |
500 | 500 |
501 | 501 |
502 class readlinehandler(urlreq.basehandler): | |
503 def http_response(self, request, response): | |
504 class readlineresponse(response.__class__): | |
505 def readlines(self, sizehint=0): | |
506 total = 0 | |
507 list = [] | |
508 while True: | |
509 line = self.readline() | |
510 if not line: | |
511 break | |
512 list.append(line) | |
513 total += len(line) | |
514 if sizehint and total >= sizehint: | |
515 break | |
516 return list | |
517 | |
518 response.__class__ = readlineresponse | |
519 return response | |
520 | |
521 https_response = http_response | |
522 | |
523 | |
502 handlerfuncs = [] | 524 handlerfuncs = [] |
503 | 525 |
504 | 526 |
505 def opener( | 527 def opener( |
506 ui, | 528 ui, |
562 handlers.extend( | 584 handlers.extend( |
563 (httpbasicauthhandler(passmgr), httpdigestauthhandler(passmgr)) | 585 (httpbasicauthhandler(passmgr), httpdigestauthhandler(passmgr)) |
564 ) | 586 ) |
565 handlers.extend([h(ui, passmgr) for h in handlerfuncs]) | 587 handlers.extend([h(ui, passmgr) for h in handlerfuncs]) |
566 handlers.append(cookiehandler(ui)) | 588 handlers.append(cookiehandler(ui)) |
589 handlers.append(readlinehandler()) | |
567 opener = urlreq.buildopener(*handlers) | 590 opener = urlreq.buildopener(*handlers) |
568 | 591 |
569 # keepalive.py's handlers will populate these attributes if they exist. | 592 # keepalive.py's handlers will populate these attributes if they exist. |
570 opener.requestscount = 0 | 593 opener.requestscount = 0 |
571 opener.sentbytescount = 0 | 594 opener.sentbytescount = 0 |