Hey everyone.
I had forked a project that promised to let me run PHP scripts trough fcgi and did slight modifications to it so it would work properly with the Yii framework. But now I just tried to print an image verbatim - changing the content type and and adding Content-length to the headers. What I had to learn was, that my output was off. I compared it to running the same script from NGINX and compared the output. It appears that the first bunch of bites are off entirely. x.x
Since I am not quite a FCGI-nut, I can not seem to fix this.
<?php
$file = "/Users/Ingwie/Downloads/xynu_icon.jpg";
header("Content-type: image/jpeg; charset=binary");
header("Content-length: ".filesize($file));
@readfile($file);
-bash: fstat: command not found
16777221 15545045 -rw-r--r-- 1 Ingwie staff 0 250937 "Jan 13 01:02:42 2015" "Dec 29 18:59:25 2014" "Dec 29 18:59:25 2014" "Dec 29 18:58:54 2014" 4096 496 0 Downloads/xynu_icon.jpg
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /blah.php HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Powered-By: PHP/5.5.14
< Content-type: image/jpeg; charset=binary
< Content-length: 250937
< X-Response-Time: 1.924ms
< Date: Tue, 13 Jan 2015 00:08:59 GMT
< Connection: keep-alive
<
{ [data not shown]
100 245k 100 245k 0 0 11.3M 0 --:--:-- --:--:-- --:--:-- 12.5M
* Connection #0 to host localhost left intact
16777221 17084144 -rw-r--r-- 1 Ingwie staff 0 250937 "Jan 13 01:09:00 2015" "Jan 13 01:08:59 2015" "Jan 13 01:08:59 2015" "Jan 13 00:52:55 2015" 4096 496 0 test.jpeg
test.jpeg Downloads/xynu_icon.jpg differ: char 1, line 1
00000000 ff d8 ff e0 00 10 4a 46 49 46 00 01 01 01 01 2c |......JFIF.....,|
00000010
00000000 ef bf bd ef bf bd ef bf bd ef bf bd 00 10 4a 46 |..............JF|
00000010
As you can see at the hexdumps at the end, something is not right with the output.
Ingwie.