You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Angela <an...@activitae.com> on 2003/10/26 00:01:14 UTC

Mod_perl returning perl scripts

Hi,

I'm using Apache with Mod_Perl configured on a win XP box.
Perl scripts prepare WML cards to return to a CGI request. This works fine
if requests come from mobile phones.
However, if I type the url into my HTML web browser pointing to a perl
script that expects WML to call it, the script, (that is the perl code
itself, not the output from the script), gets sent back to the requestor for
saving!! 

I really don't want to lose my code this way!
I have this in my perl.conf file:-

Alias /perl/ "C:/Apache2/perl/
<Location /perl>
  SetHandler perl-script
  PerlResponseHandler ModPerl::Registry
  Options +ExecCGI
  PerlOptions +ParseHeaders
</Location>

What can I do to stop files with a *.pl mask being returned to a user?

All help appreciated!

Angela

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003
 



RE: Mod_perl returning perl scripts

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Sun, 26 Oct 2003, Angela wrote:

[ ... ]
> I think(?) the issue is that the browser doesn’t know the
> contents because the header returned is a wap header i.e.
> 'Content-Type: text/vnd.wap.wml'. The browser then assumes
> it's a file download and promptly does just that! Although
> having said that, I have a browser plug-in that should
> fire up if the response is wml. It doesn't.
>
> But, while writing this I thought 'I wonder what Netscape
> does'? You guys are going to love this! Can you believe
> that Netscape does as it should and fires up my plug-in?
> Well it does. It seems this is an IE Explorer-Mod_perl
> specific problem!
>
> I still need to stop files being downloaded by IE users though!

IE sometimes has a (1/2) mind of it's own ... You might try,
just for testing, making a Windows file association with a
wml file, and seeing if IE then launches the associated
application, rather than prompting you to save.

-- 
best regards,
randy

RE: Mod_perl returning perl scripts

Posted by Angela <an...@activitae.com>.
Babs wrote:-

>I got a similar problem sometime ago; for some unknown reason, it worked
>alright after I restarted Apache afresh. Perhaps it may help you too. Let
>me know how you finally solve the problem.

>Besides that, you need to explicitly tell mod_perl to always send a header
>to the browser, by adding: "PerlSendHeader on" to the http.conf as follows:

Thanks Babs. I tried that! I think you may have altered something in the
conf file or something. And, despite Randy's assertion otherwise I added
'PerlSendHeader on' just now to no effect.

Randy wrote:-

>In your script, are you sending a header such as
>   print "Content-type: text/html\n\n";
>or some such, such that the browser knows it should display
>the contents?

Thanks Randy. I think(?) the issue is that the browser doesn’t know the
contents because the header returned is a wap header i.e. 'Content-Type:
text/vnd.wap.wml'. The browser then assumes it's a file download and
promptly does just that! Although having said that, I have a browser plug-in
that should fire up if the response is wml. It doesn't.

But, while writing this I thought 'I wonder what Netscape does'? You guys
are going to love this! Can you believe that Netscape does as it should and
fires up my plug-in? Well it does. It seems this is an IE Explorer-Mod_perl
specific problem! 

I still need to stop files being downloaded by IE users though!

Kind regards to all,

Angela


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003
 



RE: Mod_perl returning perl scripts

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Sun, 26 Oct 2003, Angela wrote:

> Stas & Randy,
>
> Thanks for the help. I removed file associations and renamed a test file to
> have no extension.
>
> There are no references to perl in http.conf apart from the very end where I
> have now copied from perl.conf.
>
> And I corrected the typo ;(  The test file without an extension, along with
> the others, still gets returned.
>
> Any other ideas will be seized upon with alacrity; I'm going crazy here!

In your script, are you sending a header such as
   print "Content-type: text/html\n\n";
or some such, such that the browser knows it should display
the contents?

-- 
best regards,
randy

RE: Mod_perl returning perl scripts

Posted by Angela <an...@activitae.com>.
Stas & Randy,

Thanks for the help. I removed file associations and renamed a test file to
have no extension. 

There are no references to perl in http.conf apart from the very end where I
have now copied from perl.conf.

And I corrected the typo ;(  The test file without an extension, along with
the others, still gets returned.

Any other ideas will be seized upon with alacrity; I'm going crazy here!

Kind regards

Angela

> Make sure that later on in httpd.conf you aren't
> redefining /perl to be handled by the default handler.
> e.g. try to move the above config to the very end of
> httpd.conf.

If you're still having problems after trying that, you might
try making sure that a Windows file association with .pl
files isn't the cause. Try renaming the script from, eg,
"testing.pl" to just "testing" to see if that helps.

-- 
best regards,
randy kobes

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003
 



Re: Mod_perl returning perl scripts

Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Sat, 25 Oct 2003, Stas Bekman wrote:

> Angela wrote:
> > Hi,
> >
> > I'm using Apache with Mod_Perl configured on a win XP box.
> > Perl scripts prepare WML cards to return to a CGI request. This works fine
> > if requests come from mobile phones.
> > However, if I type the url into my HTML web browser pointing to a perl
> > script that expects WML to call it, the script, (that is the perl code
> > itself, not the output from the script), gets sent back to the requestor for
> > saving!!
> >
> > I really don't want to lose my code this way!
> > I have this in my perl.conf file:-
> >
> > Alias /perl/ "C:/Apache2/perl/
>
> Don't you have a typo above? " is not closed.
>
> > <Location /perl>
> >   SetHandler perl-script
> >   PerlResponseHandler ModPerl::Registry
> >   Options +ExecCGI
> >   PerlOptions +ParseHeaders
> > </Location>
> >
> > What can I do to stop files with a *.pl mask being returned to a user?
>
> Make sure that later on in httpd.conf you aren't
> redefining /perl to be handled by the default handler.
> e.g. try to move the above config to the very end of
> httpd.conf.

If you're still having problems after trying that, you might
try making sure that a Windows file association with .pl
files isn't the cause. Try renaming the script from, eg,
"testing.pl" to just "testing" to see if that helps.

-- 
best regards,
randy kobes

Re: Mod_perl returning perl scripts

Posted by Stas Bekman <st...@stason.org>.
Angela wrote:
> Hi,
> 
> I'm using Apache with Mod_Perl configured on a win XP box.
> Perl scripts prepare WML cards to return to a CGI request. This works fine
> if requests come from mobile phones.
> However, if I type the url into my HTML web browser pointing to a perl
> script that expects WML to call it, the script, (that is the perl code
> itself, not the output from the script), gets sent back to the requestor for
> saving!! 
> 
> I really don't want to lose my code this way!
> I have this in my perl.conf file:-
> 
> Alias /perl/ "C:/Apache2/perl/

Don't you have a typo above? " is not closed.

> <Location /perl>
>   SetHandler perl-script
>   PerlResponseHandler ModPerl::Registry
>   Options +ExecCGI
>   PerlOptions +ParseHeaders
> </Location>
> 
> What can I do to stop files with a *.pl mask being returned to a user?

Make sure that later on in httpd.conf you aren't redefining /perl to be 
handled by the default handler. e.g. try to move the above config to the very 
end of httpd.conf.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


AW: Mod_perl returning perl scripts

Posted by "B. Fongo" <my...@fongo.de>.
I got a similar problem sometime ago; for some unknown reason, it worked
alright after I restarted Apache afresh. Perhaps it may help you too.
Let me know how you finally solve the problem.

Good luck

Babs

> -----Ursprüngliche Nachricht-----
> Von: Angela [mailto:angela@activitae.com] 
> Gesendet: Sonntag, 26. Oktober 2003 00:01
> An: modperl@perl.apache.org
> Betreff: Mod_perl returning perl scripts
> 
> 
> Hi,
> 
> I'm using Apache with Mod_Perl configured on a win XP box.
> Perl scripts prepare WML cards to return to a CGI request. 
> This works fine
> if requests come from mobile phones.resh
> However, if I type the url into my HTML web browser pointing to a perl
> script that expects WML to call it, the script, (that is the perl code
> itself, not the output from the script), gets sent back to 
> the requestor for
> saving!! 
> 
> I really don't want to lose my code this way!
> I have this in my perl.conf file:-
> 
> Alias /perl/ "C:/Apache2/perl/
> <Location /perl>
>   SetHandler perl-script
>   PerlResponseHandler ModPerl::Registry
>   Options +ExecCGI
>   PerlOptions +ParseHeaders
> </Location>
> 
> What can I do to stop files with a *.pl mask being returned to a user?
> 
> All help appreciated!
> 
> Angela
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003
>  
> 
> 
>