def do_receive(self, bytes_to_send, chunked_mode, enable_cache):
        self._logger.debug(
            'Requested to send %s bytes (chunked: %s, cache: %s)',
            bytes_to_send, chunked_mode, enable_cache)
        # Write a header
        response_header = (
            'HTTP/1.1 200 OK\r\n'
            'Access-Control-Allow-Origin: *\r\n'
            'Content-Type: application/octet-stream\r\n')
        if enable_cache:
            response_header += 'Cache-Control: private, max-age=10\r\n'
        else:
            response_header += \
                'Cache-Control: no-cache, no-store, must-revalidate\r\n'
        if chunked_mode:
            response_header += 'Transfer-Encoding: chunked\r\n\r\n'
        else:
            response_header += (
                'Content-Length: %d\r\n\r\n' % bytes_to_send)
        self.wfile.write(response_header)
        self.wfile.flush()

        # Write a body
        SEND_BLOCK_SIZE = 1024 * 1024

        while bytes_to_send > 0:
            bytes_to_send_in_this_loop = bytes_to_send
            if bytes_to_send_in_this_loop > SEND_BLOCK_SIZE:
                bytes_to_send_in_this_loop = SEND_BLOCK_SIZE

            if chunked_mode:
                self.wfile.write('%x\r\n' % bytes_to_send_in_this_loop)
            self.wfile.write('a' * bytes_to_send_in_this_loop)
            if chunked_mode:
                self.wfile.write('\r\n')
            self.wfile.flush()

            bytes_to_send -= bytes_to_send_in_this_loop

        if chunked_mode:
            self.wfile.write('0\r\n\r\n')
            self.wfile.flush()
dataset/ETHPy150Open google/pywebsocket/mod_pywebsocket/xhr_benchmark_handler.py/XHRBenchmarkHandler.do_receive/original