read body before writing response