(self, data)
write()' callable as specified by PEP 3333
write()' callable as specified by PEP 3333
write () callable as specified by PEP 3333
def write(self, data):
        """'write()' callable as specified by PEP 3333"""

        assert type(data) is bytes, \
            "write() argument must be a bytes instance"

        if not self.status:
            raise AssertionError("write() before start_response()")

        elif not self.headers_sent:
            # Before the first output, send the stored headers
            self.bytes_sent = len(data)    # make sure we know content-length
            self.send_headers()
        else:
            self.bytes_sent += len(data)

        # XXX check Content-Length and truncate if too many bytes written?
        self._write(data)
        self._flush()
def write ( self , data ) : assert type ( data ) is bytes , "write() argument must be a bytes instance" if not self . status : raise AssertionError ( "write() before start_response()" ) elif not self . headers_sent : # Before the first output, send the stored headers self . bytes_sent = len ( data ) # make sure we know content-length self . send_headers ( ) else : self . bytes_sent += len ( data ) # XXX check Content-Length and truncate if too many bytes written? self . _write ( data ) self . _flush ( )