add check for htmlMode before sending header