added a debug mode that collects HTTP headers