'Encode a buffered response body.'

def encode_string(self, encoding):

    if (encoding in self.attempted_charsets):
        return False
    self.attempted_charsets.add(encoding)
    body = []
    for chunk in self.body:
        if isinstance(chunk, unicodestr):
            try:
                chunk = chunk.encode(encoding, self.errors)
            except (LookupError, UnicodeError):
                return False
        body.append(chunk)
    self.body = body
    return True
