use threading.local to handle header