I'm making a PHP image proxy script. I need it to not only echo the contents of the image it requests, but also identically reproduce the header of the image request.
I've seen one, and the other, but not both together... and these cURL option things confuse me. How would I do this?
Sorry, I'm not sure what is you want.
This is the example to get from a image url, echo header and save image to a file.
But, if you want a proxy, you should use web server (Nginx, Apache, etc), PHP is no need
You can get all the headers (not as raw text) with
getallheaders()
Then string them back together:
Then I think the best way is to use a socket connection, rather than CURL like so:
Note that you may need to modify the host/request headers (because this is an identical copy, as you asked), and you may need to implement redirect following.