Set headers on write