#!/usr/bin/env python3
"""Serve the macOS web-content POC for the
AutofillProgressDialogControllerImpl::OnDismissed UAF.

Usage:
  python3 server.py            # serves on http://localhost:8080/
Then open http://localhost:8080/opener.html in the target macOS Chrome.
"""
import http.server
import socketserver
import os

PORT = 8080

class Handler(http.server.SimpleHTTPRequestHandler):
    def __init__(self, *a, **kw):
        super().__init__(*a, directory=os.path.dirname(os.path.abspath(__file__)), **kw)

    def end_headers(self):
        self.send_header('Cache-Control', 'no-store')
        super().end_headers()

if __name__ == '__main__':
    socketserver.TCPServer.allow_reuse_address = True
    with socketserver.TCPServer(('', PORT), Handler) as httpd:
        print(f'[*] serving POC on http://localhost:{PORT}/opener.html')
        httpd.serve_forever()
