copy logic from `self.read` to `self.write` for handling headers
copy logic from `self.read` to `self.write` for handling headers

airbnb/knowledge-repo,airbnb/knowledge-repo,airbnb/knowledge-repo,airbnb/knowledge-repo,airbnb/knowledge-repo