Ah, mod-perl....{{{ shudder }}}.

"$asperl->setContentType($apache->content_type());"

I think there's a bunch of relevant code we're not seeing.  Without having been 
set prior, I don't believe $apache->content_type will return the right header 
in this situation because it relies on file extension and will typically fail 
to "text/html". Just for debugging purposes, have you tried simply changing the 
code to:

$asperl->setContentType($apache->content_type('image/jpeg'));



>>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/
>>



-----Message Disclaimer-----

This e-mail message is intended only for the use of the individual or
entity to which it is addressed, and may contain information that is
privileged, confidential and exempt from disclosure under applicable law.
If you are not the intended recipient, any dissemination, distribution or
copying of this communication is strictly prohibited. If you have
received this communication in error, please notify us immediately by
reply email to conn...@principal.com and delete or destroy all copies of
the original message and attachments thereto. Email sent to or from the
Principal Financial Group or any of its member companies may be retained
as required by law or regulation.

Nothing in this message is intended to constitute an Electronic signature
for purposes of the Uniform Electronic Transactions Act (UETA) or the
Electronic Signatures in Global and National Commerce Act ("E-Sign")
unless a specific statement to the contrary is included in this message.

While this communication may be used to promote or market a transaction
or an idea that is discussed in the publication, it is intended to provide
general information about the subject matter covered and is provided with
the understanding that The Principal is not rendering legal, accounting,
or tax advice. It is not a marketed opinion and may not be used to avoid
penalties under the Internal Revenue Code. You should consult with
appropriate counsel or other advisors on all matters pertaining to legal,
tax, or accounting obligations and requirements.


--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/


Reply via email to