def do_GET(self):
        'Serve the specified file when requested, return errors otherwise'
        # The only request path to accept is '/self.server.allowed_file'.
        if self.path != '/' + os.path.basename(self.server.allowed_file):
            self.send_error(403)
            return

        try:
            fout = open(self.server.allowed_file)
        except __HOLE__:
            self.send_error(404)
            return

        self.send_response(200)
        mimetypes.init()
        mime_guess = mimetypes.guess_type(self.server.allowed_file)
        if mime_guess[0] is not None:
            self.send_header('Content-Type', mime_guess[0])
        if mime_guess[1] is not None:
            self.send_header('Content-Encoding', mime_guess[1])
        statinfo = os.stat(self.server.allowed_file)
        self.send_header('Content-Length', statinfo.st_size)
        self.end_headers()
        try:
            self.wfile.write(fout.read())
        except socket.error, e:
            # EPIPE likely means the client's closed the connection,
            # it's nothing of concern so suppress the error message.
            if errno.errorcode[e[0]] == 'EPIPE':
                pass

        fout.close()
        return
dataset/ETHPy150Open cjlee112/pygr/tests/testlib/megatest_utils.py/MinimalistHTTPRequestHandler.do_GET