'Compute Content-Length or switch to chunked encoding if possible'

def set_content_length(self):

    try:
        blocks = len(self.result)
    except (TypeError, AttributeError, NotImplementedError):
        pass
    else:
        if (blocks == 1):
            self.headers['Content-Length'] = str(self.bytes_sent)
            return
