'Encode a streaming response body.
Use a generator wrapper, and just pray it works as the stream is
being written out.'

def encode_stream(self, encoding):

    if (encoding in self.attempted_charsets):
        return False
    self.attempted_charsets.add(encoding)
    def encoder(body):
        for chunk in body:
            if isinstance(chunk, unicodestr):
                chunk = chunk.encode(encoding, self.errors)
            (yield chunk)
    self.body = encoder(self.body)
    return True
