##// END OF EJS Templates
keepalive: track number of bytes received from an HTTP response...
Gregory Szorc -
r40069:5e5b0608 default
parent child Browse files
Show More
@@ -392,6 +392,7 b' class HTTPResponse(httplib.HTTPResponse)'
392 392 method=method, **extrakw)
393 393 self.fileno = sock.fileno
394 394 self.code = None
395 self.receivedbytescount = 0
395 396 self._rbuf = ''
396 397 self._rbufsize = 8096
397 398 self._handler = None # inserted by the handler later
@@ -436,7 +437,16 b' class HTTPResponse(httplib.HTTPResponse)'
436 437 # if it's not empty.
437 438 s = self._rbuf
438 439 self._rbuf = ''
439 s += self._raw_read(amt)
440 data = self._raw_read(amt)
441
442 self.receivedbytescount += len(data)
443 self._connection.receivedbytescount += len(data)
444 try:
445 self._handler.parent.receivedbytescount += len(data)
446 except AttributeError:
447 pass
448
449 s += data
440 450 return s
441 451
442 452 # stolen from Python SVN #68532 to fix issue1088
@@ -512,6 +522,13 b' class HTTPResponse(httplib.HTTPResponse)'
512 522 if not new:
513 523 break
514 524
525 self.receivedbytescount += len(new)
526 self._connection.receivedbytescount += len(new)
527 try:
528 self._handler.parent.receivedbytescount += len(new)
529 except AttributeError:
530 pass
531
515 532 chunks.append(new)
516 533 i = new.find('\n')
517 534 if i >= 0:
@@ -557,6 +574,14 b' class HTTPResponse(httplib.HTTPResponse)'
557 574 return total
558 575 mv = memoryview(dest)
559 576 got = self._raw_readinto(mv[have:total])
577
578 self.receivedbytescount += got
579 self._connection.receivedbytescount += got
580 try:
581 self._handler.receivedbytescount += got
582 except AttributeError:
583 pass
584
560 585 dest[0:have] = self._rbuf
561 586 got += len(self._rbuf)
562 587 self._rbuf = ''
@@ -643,6 +668,7 b' class HTTPConnection(httplib.HTTPConnect'
643 668 def __init__(self, *args, **kwargs):
644 669 httplib.HTTPConnection.__init__(self, *args, **kwargs)
645 670 self.sentbytescount = 0
671 self.receivedbytescount = 0
646 672
647 673 #########################################################################
648 674 ##### TEST FUNCTIONS
General Comments 0
You need to be logged in to leave comments. Login now