Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Perl script timeout problem

Reply
Thread Tools

Perl script timeout problem

 
 
Brian McCauley
Guest
Posts: n/a
 
      02-19-2005


sipitai wrote:

> Brian McCauley wrote...
>
>
>>
>>if ( key_has_expired ) {
>> display_error_page;
>>} else {
>> perform_internal_redirect; # Client never sees the real URL
>>}

>
>
> Although now im not entirely sure what you mean by performing an
> internal redirect to the file.


You put the file in a directory that where it would be directly
accessible by a URL but don't tell anyone the directory.

Your CGI script then sends a CGI response to the web server that tells
it to genereate an HTTP response as if it had gotten a simple GET
request for the file.

You may even be able to configure your web server so that requests to
the secret directory that do not come via an internal redirect are
declined. This way wouldn't need to keep it secret.

(Nore of this, of course, has the slightest thing to do with Perl).

> If you could explain this in a bit more detail,


One way for a Perl script to send an internal redirect CGI response
would be:

print "Location: /some/non/published/path/$file\n\n";

Note that an internal redirect does have the
'http://someserver.example.com/' prefix but starts at the '/' that is
the root of the current (virtual) server.

You could possibly use the redirect() method from CGI.pm rather than a
raw print() but this also generates a "Status:" header and I suspect
this may confuse some web servers into generating an external redirect.

You need to ensure that you web server software is configured not to
include 'helpful' Content-location headers that contain the true URL of
HTTP entities that resolve via internal redirects.

> ...or point me in the direction of a website that covers this
> subject, I would be greatly appreciative.


Any website containing CGI reference or tutorial documentation should
cover this.

 
Reply With Quote
 
 
 
 
sipitai
Guest
Posts: n/a
 
      02-28-2005
"Jürgen Exner" wrote...

> Are you using alarm() in you program?
> If not then it's the environment that is triggering the timeout.


Im not using alarm() anywhere in the script.

And do I realise its the environment that's actually triggering the
time out, rather than the script. Although what I was trying to ask in
my original statement was, is it more likely that there is a problem
with the environment that requires some sort of fix, or is it more
likely that there is a problem with the script that requires some sort
of fix (For example, I figure that perhaps the script might need to be
updated to somehow let the server know that it is transferring data,
or that it is still running, etc. to prevent the time out from
occurring) ?
 
Reply With Quote
 
 
 
 
sipitai
Guest
Posts: n/a
 
      02-28-2005
"Jürgen Exner" wrote...

> Do you have a Perl question, too?
> Otherwise I would suggest you head over to the CGI NGs because your question
> has _very_little_ to do with Perl but a _whole_lot_ with CGI and web
> authoring.


Yes, check out my original post. I just added this description for
those people who wanted to do a bit of lateral thinking and suggest
some alternative methods of implementing a solution.
 
Reply With Quote
 
sipitai
Guest
Posts: n/a
 
      02-28-2005
Brian McCauley wrote...

> You put the file in a directory that where it would be directly
> accessible by a URL but don't tell anyone the directory.
>
> Your CGI script then sends a CGI response to the web server that tells
> it to genereate an HTTP response as if it had gotten a simple GET
> request for the file.
>
> You may even be able to configure your web server so that requests to
> the secret directory that do not come via an internal redirect are
> declined. This way wouldn't need to keep it secret.
>
> (Nore of this, of course, has the slightest thing to do with Perl).
>
> One way for a Perl script to send an internal redirect CGI response
> would be:
>
> print "Location: /some/non/published/path/$file\n\n";
>
> Note that an internal redirect does have the
> 'http://someserver.example.com/' prefix but starts at the '/' that is
> the root of the current (virtual) server.
>
> You could possibly use the redirect() method from CGI.pm rather than a
> raw print() but this also generates a "Status:" header and I suspect
> this may confuse some web servers into generating an external redirect.
>
> You need to ensure that you web server software is configured not to
> include 'helpful' Content-location headers that contain the true URL of
> HTTP entities that resolve via internal redirects.


That is a fairly good idea, although it requires the files to be
located directly on the hard disk, where as in this case the files are
are stored in a blob field in a MySQL database.

So as far as I know im still going to require a script to allow the
user to download the files, unless I start writing temporary files to
the hard disk, which is something I would like to avoid doing. But its
possible I might have missed something here.

Perhaps another way of looking at this problem would be to ask, what
is the most reliable way of allowing a user to download a file stored
in a blob field in a MySQL database, without having to write a
temporary file to the hard disk?
 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      02-28-2005


sipitai wrote:

> Perhaps another way of looking at this problem would be to ask, what
> is the most reliable way of allowing a user to download a file stored
> in a blob field in a MySQL database, without having to write a
> temporary file to the hard disk?


When serving up entities of non-trivial size there are all sorts of
considerations about entitity tags and partial responses if you want to
do it properly. None of this relates to Perl and is oft discussed in
newsgroups where it is on-topic.

 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      02-28-2005


sipitai wrote:

> Perhaps another way of looking at this problem would be to ask, what
> is the most reliable way of allowing a user to download a file stored
> in a blob field in a MySQL database, without having to write a
> temporary file to the hard disk?


Are you slurping the whole BLOB into a Perl variable? Perhaps you are
having problems with your CGI process going swap-bound. Try reading it
in chunks. (How you'd do this is SQL-dialect specific).

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in passing values to perl script using another perl script vikrant Perl Misc 4 08-10-2005 06:20 PM
Timeout::timeout and Socket timeout Mark Probert Ruby 1 10-06-2004 09:30 AM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments