You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by John Michael <jo...@acadiacom.net> on 2003/11/30 10:08:45 UTC
Once more connection monitoring
>
> Be aware of proxies. Many ISPs use proxies, in this situation your are
> excluding all people using the same proxy because one of their users is
> accessing a directory/file.
>
I'm not worried about this aspect. I'm going to validate using cookies and
can use cookies along with their ip, user agent, and lang var to come up with a scheme.
I'm more worried about whether or not I am on the right track with this
section of code layout.
IF i wanted to allow a validated user to download one file at a time from a certain folder
sub handler {
# validate user first to see if they belong in this area
# check and see if this user already has an active connection and is currently downloading a file by maintaining this information in some way(memory cache, flat file, db)don't know or can you poll the active connections on the server or would that take too more resources
# if already active return FORBIDDEN else
# add user to active connections list if not already active
$r->push_handlers(PerlCleanupHandler => \&cleanup);
return OK;
}
sub cleanup {
# remove active connections here b/c I won't be called until either the file is through being sent or user terminated connection freeing up services for this user to download another file
}
Is this correct.
John Michael
Re: Once more connection monitoring
Posted by Perrin Harkins <pe...@elem.com>.
> I'm more worried about whether or not I am on the right track with this
> section of code layout.
>
> IF i wanted to allow a validated user to download one file at a time
> from a certain folder sub handler {
> # validate user first to see if they belong in this area
> # check and see if this user already has an active connection and is
> currently downloading a file by maintaining this information in some
> way(memory cache, flat file, db)don't know or can you poll the
> active connections on the server or would that take too more
> resources
If you're concerned about speed, putting the data in MySQL, IPC::MM, or
BerkeleyDB should be fast enough. Only MySQL in that list will work for
multiple machines.
> sub cleanup {
> # remove active connections here b/c I won't be called until either
> the file is through being sent or user terminated connection freeing
> up services for this user to download another file
A cleanup handler is the right place to do it, but you typically don't get
interrupted when the user terminates the connection. Read more here:http://perl.apache.org/docs/1.0/guide/debug.html#Handling_the__User_pressed_Stop_button__case
- Perrin
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html