'raw data to HTTP response'

def upstream_recv(self, data):

    try:
        if self.closed:
            return
        d = data.peek()
        encoded_data = base64.b64encode(d)
        response = ('HTTP/1.1    %s\r\n' % self.response_code)
        for (name, value) in self.headers.iteritems():
            response += ('%s:    %s\r\n' % (name, value))
        response += ('Content-Length:    %s\r\n' % len(encoded_data))
        response += '\r\n'
        response += encoded_data
        self.downstream.write(response)
        data.drain(len(d))
    except Exception as e:
        logging.debug(e)
