Execute a listener when a response is about to write headers.