def sendErrorResponseForRequest(self, receivedConnectedSIPMessage, statusCodeInteger=500, reasonPhraseString='Server Error', descriptionString='An unknown server error occurred.'):
     # TODO: I believe we need to reliably send this response, including retransmission, etc.  For now, just send the damn thing.
     # Response header fields to include in a response are documented in RFC3261 8.2.6
     sipRequestReplyingTo = receivedConnectedSIPMessage.sipMessage
     connection = receivedConnectedSIPMessage.connection
     sipResponse = SIPResponse.newForAttributes(statusCode=statusCodeInteger, reasonPhrase=reasonPhraseString)
     if sipRequestReplyingTo.header.toTag:
         sipResponse.header.addHeaderField(sipRequestReplyingTo.header.toHeaderField)
     else:
         hf = sipRequestReplyingTo.header.toHeaderField.deepCopy
         # TODO:  See RFC3261 section 8.2.7 last point - tag must be invariant for identical To headers.  So need to write a method to generate an invariant tag.
         hf.generateTag()
         sipResponse.header.addHeaderField(hf)
     sipResponse.header.addHeaderField(sipRequestReplyingTo.header.fromHeaderField)
     sipResponse.header.addHeaderField(sipRequestReplyingTo.header.callIDHeaderField)
     sipResponse.header.addHeaderField(sipRequestReplyingTo.header.cSeqHeaderField)
     sipResponse.header.addHeaderFields(sipRequestReplyingTo.viaHeaderFields)
     sipResponse.header.addHeaderField(ContentLengthSIPHeaderField.newForIntegerValue(0))
     sipResponse.clearRawString()
     connection.sendMessage(sipResponse)
 def newContentLengthHeaderFieldForSIPMessage(self, aSIPMessage):
     return ContentLengthSIPHeaderField.newForIntegerValue(len(aSIPMessage.body))