'WSGI callable to write unbuffered data to the client.
This method is also used internally by start_response (to write
data from the iterable returned by the WSGI application).'

def write(self, chunk):

    if (not self.started_response):
        raise AssertionError('WSGI    write    called    before    start_response.')
    chunklen = len(chunk)
    rbo = self.remaining_bytes_out
    if ((rbo is not None) and (chunklen > rbo)):
        if (not self.req.sent_headers):
            self.req.simple_response('500    Internal    Server    Error', 'The    requested    resource    returned    more    bytes    than    the    declared    Content-Length.')
        else:
            chunk = chunk[:rbo]
    if (not self.req.sent_headers):
        self.req.sent_headers = True
        self.req.send_headers()
    self.req.write(chunk)
    if (rbo is not None):
        rbo -= chunklen
        if (rbo < 0):
            raise ValueError('Response    body    exceeds    the    declared    Content-Length.')
