I can't get mPDF to load some images I'm serving from a controller. It seems that mPDF uses HTTP/1.0 requests and it gets back a 302 redirect.
Apache access logs from mPDF; /img/missing-image-640x360.png
loads directly from the filesystem and works; /products/showImage/
is my controller action to output images and it sends a 302.
127.0.0.1 - - [09/Feb/2016:19:56:30 +0200] "GET /img/missing-image-640x360.png HTTP/1.0" 200 5407
127.0.0.1 - - [09/Feb/2016:19:56:30 +0200] "GET /products/showImage/1454838253_0d52e1e46e0de6dfa2aa01490f986ff6.png HTTP/1.0" 302 -
127.0.0.1 - - [09/Feb/2016:19:56:30 +0200] "GET /index HTTP/1.0" 200 6439
127.0.0.1 - - [09/Feb/2016:19:56:30 +0200] "GET /products/showImage/1454838253_0d52e1e46e0de6dfa2aa01490f986ff6.png HTTP/1.0" 302 -
127.0.0.1 - - [09/Feb/2016:19:56:30 +0200] "GET /index HTTP/1.0" 200 6439
127.0.0.1 - - [09/Feb/2016:19:56:30 +0200] "GET /products/showImage/1454838253_0d52e1e46e0de6dfa2aa01490f986ff6.png HTTP/1.1" 302 -
Loading the same content as HTML in browser works fine:
127.0.0.1 - - [09/Feb/2016:19:57:13 +0200] "GET /img/missing-image-640x360.png HTTP/1.1" 304 -
127.0.0.1 - - [09/Feb/2016:19:57:13 +0200] "GET /products/showImage/1454838253_0d52e1e46e0de6dfa2aa01490f986ff6.png HTTP/1.1" 200 46118
The showImage
action does this:
$image = new \Phalcon\Image\Adapter\GD($path);
$response = new \Phalcon\Http\Response();
$response->setContentType($image->getMime());
$response->setContent($image->render());
return $response;
Can I make phalcon reply using version 1.0? Or any other suggestion welcomed.