Show More
@@ -384,6 +384,7 b' class HTTPResponse(httplib.HTTPResponse)' | |||||
384 | self._connection = None # (same) |
|
384 | self._connection = None # (same) | |
385 |
|
385 | |||
386 | _raw_read = httplib.HTTPResponse.read |
|
386 | _raw_read = httplib.HTTPResponse.read | |
|
387 | _raw_readinto = getattr(httplib.HTTPResponse, 'readinto', None) | |||
387 |
|
388 | |||
388 | def close(self): |
|
389 | def close(self): | |
389 | if self.fp: |
|
390 | if self.fp: | |
@@ -523,12 +524,24 b' class HTTPResponse(httplib.HTTPResponse)' | |||||
523 | return list |
|
524 | return list | |
524 |
|
525 | |||
525 | def readinto(self, dest): |
|
526 | def readinto(self, dest): | |
526 | res = self.read(len(dest)) |
|
527 | if self._raw_readinto is None: | |
527 | if not res: |
|
528 | res = self.read(len(dest)) | |
528 |
|
|
529 | if not res: | |
529 |
|
530 | return 0 | ||
530 | dest[0:len(res)] = res |
|
531 | dest[0:len(res)] = res | |
531 | return len(res) |
|
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 | def safesend(self, str): |
|
546 | def safesend(self, str): | |
534 | """Send `str' to the server. |
|
547 | """Send `str' to the server. |
General Comments 0
You need to be logged in to leave comments.
Login now