'Set the HTTP status response code, but takes care that this is called
before any data is written.'

def setResponseCode(self, code, message=None):

    assert (not self.written), ('Response    code    cannot    be    set    after    data    has    been    written:    %s.' % '@@@@'.join(self.written))
    self.responseCode = code
    self.responseMessage = message
