in reply to Sending an image to a browser
After some more trial and error, I was able to solve the situation. Thanks everyone for your help. The following are my comments to your recomendations.
Cody Pendant:
I used these:
Content-type: image/gif and Content-type: image/jpeg . Both failed.
bsdz:
This, regretfully, didn't work.
dorward:
>What does $in{image} contain?
The image file name to display.
>Have you checked it contains what you expect?
Yes, and it has the correct information (excluding the 'secret' dir).
>Exactly what HTTP headers are being output?
See above (Cody Pendant).
>If you visit ..... visibly redirected?
No, either get nothing, or an error about incorrect headders from the image file.
pearlie:
Thanks but, I'm not really a fan of perl OOP. I prefer the KISS moto, and sending my own information to the browser that way I know what's being sent. Yes, perl OOP makes life simpler, but I simply keep to what I know works and write my own headders.
zentara:
The browser fills in the URL, so /cgi-bin/my.cgi?image=images/some.jpg becomes http://www.example.com/cgi-bin/my.cgi?image=images/some.jpg. Leaving off the / at the begining, through things 'out of wack' and I end up with cgi-bin calles where they shouldn't be. Keeping the / at the begining ensures that the call accesses the cgi-bin where I expect it to.
dwildesnl:
Thanks, however, I didn't want to do this. I do have space limits on the server, and simply wanted to move the images to a new location and have the cgi serve them from there to keep people from being able to link directly to them. Granted they can link to the them via the cgi, however, I can set the cgi to refuse access to the images if the refer isn't from my site. The refer should always be present in this case, and from my site, since the images being called are from within the page. I've done some testing (not through though), and the result is always that the image call has the refer information.
So, to the solution:
The information from dorward got me thinking. I moved the images to a different dir outside of the cgi-bin, and then went through the different tests I had preformed until I found out what was needed. The solution isn't exactly what I disired, however it works. I simply use print "Location: /svrimgs/$in{image}\n\n"; and presto, the images show up. No headder needed. Most likely I can chmod the dir in the cgi-bin with the right tags and/or set the .htaccess with the right information, and then the cgi can serve the images from the cgi-bin. Its something to play with, but using an images dir that only the cgi script knows about, should keep the images from being hot-linked, which is the first of two goals (the second being having the cgi only serve the real image if the refer tag contains the right information, if not, serve another image stating the image can only be accessed from the site directly. Draw back is, is like dorward explains, where firewalls remove the refer tag. But, we can't have everything our way).
Thanks all.