Show More
@@ -384,6 +384,7 b' class HTTPResponse(httplib.HTTPResponse)' | |||
|
384 | 384 | self._connection = None # (same) |
|
385 | 385 | |
|
386 | 386 | _raw_read = httplib.HTTPResponse.read |
|
387 | _raw_readinto = getattr(httplib.HTTPResponse, 'readinto', None) | |
|
387 | 388 | |
|
388 | 389 | def close(self): |
|
389 | 390 | if self.fp: |
@@ -523,12 +524,24 b' class HTTPResponse(httplib.HTTPResponse)' | |||
|
523 | 524 | return list |
|
524 | 525 | |
|
525 | 526 | def readinto(self, dest): |
|
527 | if self._raw_readinto is None: | |
|
526 | 528 | res = self.read(len(dest)) |
|
527 | 529 | if not res: |
|
528 | 530 | return 0 |
|
529 | ||
|
530 | 531 | dest[0:len(res)] = res |
|
531 | 532 | return len(res) |
|
533 | total = len(dest) | |
|
534 | have = len(self._rbuf) | |
|
535 | if have >= total: | |
|
536 | dest[0:total] = self._rbuf[:total] | |
|
537 | self._rbuf = self._rbuf[total:] | |
|
538 | return total | |
|
539 | mv = memoryview(dest) | |
|
540 | got = self._raw_readinto(mv[have:total]) | |
|
541 | dest[0:have] = self._rbuf | |
|
542 | got += len(self._rbuf) | |
|
543 | self._rbuf = '' | |
|
544 | return got | |
|
532 | 545 | |
|
533 | 546 | def safesend(self, str): |
|
534 | 547 | """Send `str' to the server. |
General Comments 0
You need to be logged in to leave comments.
Login now