Regarding the buffering, my understanding is that it is only to prevent having to slurp the entire file into memory (which I may be doing anyhow at this point, but it is not necessary to do so). For a large file, that buffering would come in handy so as not to need to consume so much RAM in the process. So I don't see any real connection between the buffering and the http headers. Now, this is merely my interpretation--someone here may be able to enlighten me as to the true purpose of the buffering.