MCPcopy
hub / github.com/aio-libs/aiohttp / write

Method write

aiohttp/protocol.py:692–728  ·  aiohttp/protocol.py::HttpMessage.write

Writes chunk of data to a stream by using different writers. writer uses filter to modify chunk of data. write_eof() indicates end of stream. writer can't be used after write_eof() method being called. write() return drain future.

(self, chunk, *,
              drain=False, EOF_MARKER=EOF_MARKER, EOL_MARKER=EOL_MARKER)

Source from the content-addressed store, hash-verified

690 self.headers[hdrs.CONNECTION] = connection
691
692 def write(self, chunk, *,
693 drain=False, EOF_MARKER=EOF_MARKER, EOL_MARKER=EOL_MARKER):
694 class="st">"""Writes chunk of data to a stream by using different writers.
695
696 writer uses filter to modify chunk of data.
697 write_eof() indicates end of stream.
698 writer can&class="cm">#x27;t be used after write_eof() method being called.
699 write() return drain future.
700 class="st">"""
701 assert (isinstance(chunk, (bytes, bytearray)) or
702 chunk is EOF_MARKER), chunk
703
704 size = self.output_length
705
706 if self._send_headers and not self.headers_sent:
707 self.send_headers()
708
709 assert self.writer is not None, &class="cm">#x27;send_headers() is not called.'
710
711 if self.filter:
712 chunk = self.filter.send(chunk)
713 while chunk not in (EOF_MARKER, EOL_MARKER):
714 if chunk:
715 self.writer.send(chunk)
716 chunk = next(self.filter)
717 else:
718 if chunk is not EOF_MARKER:
719 self.writer.send(chunk)
720
721 self._output_size += self.output_length - size
722
723 if self._output_size > 64 * 1024:
724 if drain:
725 self._output_size = 0
726 return self.transport.drain()
727
728 return ()
729
730 def write_eof(self):
731 self.write(EOF_MARKER)

Callers 15

write_eofMethod · 0.95
getMethod · 0.45
getMethod · 0.45
getMethod · 0.45
handle_requestMethod · 0.45
write_bytesMethod · 0.45
handle_errorMethod · 0.45
handle_requestMethod · 0.45
handle_requestMethod · 0.45
_responseMethod · 0.45
send_headersMethod · 0.45

Calls 3

send_headersMethod · 0.95
drainMethod · 0.80
sendMethod · 0.45

Tested by 15

handle_requestMethod · 0.36
_responseMethod · 0.36
data_receivedMethod · 0.36
expect_handlerMethod · 0.36
test_static_file_hugeMethod · 0.36
test_write_payload_eofFunction · 0.36