add writeHeader to response