The interesting part is that lighttpd with sendfile(2) works fine. looking at ktrace, the only difference i can see for now is that lighttpd does not use any header argument, but i really don't know where the corruption comes from. I've not been able to reproduce the issue with a custom C code.