> -----Original Message----- > > What are you using in showImage.html to print the image? If you're > doing it manually, then put "print 'Content-Type: image/jpeg\n" at the > top of the file (w/ a double "\n" at end of header). If using CGI.pm, > then it's as simple as "print header(-type=>'image/jpeg')" or > equivalent. If it's an Apache::* module, then there's a similar > interface, and so on. More than likely what really matters is what > showImage.html is doing (and/or not). > -- > Shaun Fryer > http://sourcery.ca/ > > On Thu, Jul 2, 2009 at 3:11 PM, Hellman, > Matthew<hellman.matt...@principal.com> wrote: > > I don't think that's it's a web server thing, because he's dynamically > generating the images and not using a .jpg extension. Doing it this way > allows you do such things as resize the image on the fly using URL > parameters. Something like: > > > > src="/images/showImage.html?imageid=123456&size=800x600 > > > > the HTTP response headers would probably shed the most light on the > problem, nudge, nudge;-) > > > >>>-----Original Message----- > >>>From: Gunnar Hjalmarsson [mailto:nore...@gunnar.cc] > >>>Sent: Thursday, July 02, 2009 1:24 PM > >>>To: beginners-cgi@perl.org > >>>Subject: Re: content type headers > >>> > >>>Hellman, Matthew wrote: > >>>> The answer to your problem seems to be making sure one and only one > >>>> content-type header is returned with the image, and that it has the > >>>> correct value (e.g. Content-Type: image/jpeg or whatever). > >>> > >>>Right, and it just struck me that this is probably a web server > >>>configuration issue. A sensibly configured server should send the > >>>correct content-type header out from the file extension. > >>> > >>>Please see the attached file, which is the config file for this > purpose > >>>on my own (Apache) server. There you can see that a jpg extension > >>>results in content-type image/jpeg, a png extension gives image/png > etc.
Thanx for all the replies. I must say this list is quite slow compared to others. Matthew is correct. I used the FF live-headers add-on and the section for the /images/showImage.html was Content-Type text/html. As for how the page is generated and images displayed, it's a bit involved. The whole application is a mod_perl wrapper and templating system. The showImage.html page is one line that reads as follows: <%- httpContentType('image/jpeg')%><%= ModName::outputImage( cgiParam('imageid'))%> I have tried to go throught the code and find out what sub-class the httpContentType is but my efforts to hack the code and force the correct content_type have failed. cgiParma is a sub-class of CGI. I'm in a pickle because the consequences of this bug are far-reaching. I'm not in a position to throw out the whole mod_perl application and I can't think of a way to serve the content that is not htmh from another handler. Below is an extract from the mod_perl handler that should be setting the content type, I have commented out my hack as it didn't work ;-( Thanx, Dp. sub handler { # THIS IS THE IMPORTANT FUNCTION my($apache)=...@_; my $asperl; if($apache->dir_config('ProjectName') && defined($OBJECT{$apache->dir_config('ProjectName')}) && ref($OBJECT{$apache->dir_config('ProjectName')})) { $asperl=$OBJECT{$apache->dir_config('ProjectName')}; } else { $asperl=$OBJECT{"DEFAULT"}; } if($apache->dir_config("ServerPort")) { $ENV{"SERVER_PORT"}=80; } my $data; # initialise the ASPerl object for this request my $fname=$apache->filename(); $asperl->{"Request"}=$apache; # finish initialising the ASPerl object if(handleThisRequest($asperl,$fname)) { # we've decided that we want to handle this, so run it through the ASPerl engine. $asperl->{"ReturnCode"}=OK; $asperl->{"CGI"}=new CGI; # my %media_hacks = ( # 'showImage.html' => 'image/jpeg', # ); # if (exists $media_hacks{basename($fname)}) { # print STDERR "Forcing content_type to $media_hacks{basename($fname)}\n"; # $asperl->setContentType($media_hacks{basename($fname)}); # $asperl->{'Request'}->content_type( $media_hacks{basename($fname)} ); # $asperl->{'Request'}->header_out( "Content-Type" =>$media_hacks{basename($fname)} ); # } # else { # print STDERR "The current type for request to $fname is ".$apache->content_type()." The ASPerl is ".$asperl->{'ContentType'}."\n"; # print STDERR "ContentType for $fname is now ".$asperl->{'Request'}->content_type."\n"; # } $asperl->setContentType($apache->content_type()); -- To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org For additional commands, e-mail: beginners-cgi-h...@perl.org http://learn.perl.org/