PHP导致文件下载格式错误

The situation is pretty straight forward :

PHP 5.3.2 is being used as an intermediary to handle (obfuscate) some static files on a server. This process has been in place for a while (1-2years). Recently (last several days) some files are having their EOF markers truncated / malformed. These files themselves have not changed in some cases for over a year or 2 as well.

What I have tried:

readfile() , file_get_contents, and fopen(), fread(), fclose() processes

The files on the server, when directly linked to, are downloaded without PHP handling them, and their EOF ( specifically %%EOF ) is maintained.

However, after PHP handles them and sends them down to the client,the %%EOF becomes %%E and the file is considered corrupted by the application native to them. The remainder lost is a portion of the 4096 chunk (usually around 3.1kb )

to me this says that the stream is terminating prematurely and the remaining bytes never make it out of the buffer - however everything I have tried, still seems to leave these off the end of the file.

some environment info :

Files are UTF-8, PHP ini has default encoding set to UTF-8, php detects utf-8 encoding of the file during processing, stream chunksize has not been changed (4096), gzip via IIS not PHP module.

Not all files fetched via this process suffer from this malformation. Reviewing file composure, size, creation date, etc.. there does not appear to be any real commonality between failing files. Nor is there a distinguishable characteristic between files which pass and files which are corrupted

Thanks in advance