Consume all data from the socket, close the response and return the data. If stream=True, then a generator is returned instead and the caller is responsible for closing the response.
(self, response, stream, tty=True, demux=False)
| 422 | yield from response.iter_content(chunk_size, decode) |
| 423 | |
| 424 | def _read_from_socket(self, response, stream, tty=True, demux=False): |
| 425 | """Consume all data from the socket, close the response and return the |
| 426 | data. If stream=True, then a generator is returned instead and the |
| 427 | caller is responsible for closing the response. |
| 428 | """ |
| 429 | socket = self._get_raw_response_socket(response) |
| 430 | |
| 431 | gen = frames_iter(socket, tty) |
| 432 | |
| 433 | if demux: |
| 434 | # The generator will output tuples (stdout, stderr) |
| 435 | gen = (demux_adaptor(*frame) for frame in gen) |
| 436 | else: |
| 437 | # The generator will output strings |
| 438 | gen = (data for (_, data) in gen) |
| 439 | |
| 440 | if stream: |
| 441 | return gen |
| 442 | else: |
| 443 | try: |
| 444 | # Wait for all frames, concatenate them, and return the result |
| 445 | return consume_socket_output(gen, demux=demux) |
| 446 | finally: |
| 447 | response.close() |
| 448 | |
| 449 | def _disable_socket_timeout(self, socket): |
| 450 | """ Depending on the combination of python version and whether we're |