i want to interrupt the file sending. but i can't change the client. so i need change the server.
All things go well, but the message i wanna response seem not work.
is the self.transport.loseConnection() (the last line) blocking the messages?
in fact, i work on Cumulus(nimbus project) which based on twisted. And i use s3cmd as the client.

here is the my code:

        def headerReceived(self,line):
        pycb.log(logging.INFO, "===== def headerReceived of cumulus.py")
        http.HTTPChannel.headerReceived(self,line)
        pycb.log(logging.INFO, "===== self.length is %s"%self.length)
        
        header, data = line.split(':', 1)
        header = header.lower()
        data = data.strip()
        if header=='authorization':
            self.authorization=data
            
        
        if self.length and self.authorization:
            user_id = self.authorization.split(':')[0].split()[1].strip()
            user = pycb.config.auth.get_user(user_id)
    
            pycb.log(logging.INFO, "===== user who put this object is %s"%user)
            
            remaining_quota = user.get_remaining_quota()
            pycb.log(logging.INFO, "===== remaining_quota is %s"%remaining_quota)
            quota_check=self.length-remaining_quota
            pycb.log(logging.INFO, "===== quota_check=self.length-remaining_quota of cumulus.py")
            
            if quota_check>0:
                requestId = str(uuid.uuid1()).replace("-", "")
                ex=cbException('AccountProblem')
                
                m_msg = "HTTP/1.1 %s %s\r\n" % (ex.httpCode, ex.httpDesc)
                self.transport.write(m_msg)
                
                m_msg = "%s: %s\r\n" % (('x-amz-request-id', requestId))
                self.transport.write(m_msg)
                #req.setHeader('x-amz-request-id', requestId)
                
                m_msg = "%s: %s\r\n" % (('x-amz-id-2', str(uuid.uuid1())))
                self.transport.write(m_msg)
                
                e_msg = ex.make_xml_string(self._path, str(uuid.uuid1()))
                pycb.log(logging.INFO, "===== e_msg is %s"%e_msg)
                #self.transport.write("\r\n")
                self.transport.write(e_msg)
                pycb.log(logging.INFO, "===== self.transport.write(e_msg)")
                
                
                self.transport.loseConnection()