def testMakingResponses(self): self.assertEqual( makeResponse( "HTTP/1.0", "200", "OK", ( ("Content-type", "text/html"), ("Content-length", "3 yards"), ), "<html><plaintext>" ), "\r\n".join(( "HTTP/1.0 200 OK", "Content-type: text/html", "Content-length: 3 yards", "", "<html><plaintext>" )) )
def composeResponse(d, lb=linebreak): """ Compose a message from a dictionary as returned by parseResponse. """ return makeResponse(d["version"], d["status"], d["reason"], d["headers"], d["entity"], lb)