You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Lang, Cliff" <cl...@proxicom.com> on 2000/09/28 21:42:28 UTC

?? Server-push or sending multipart (multiple pages) data to clie nt

With Apache 1.3, mod_perl 1.21 

How can I gererate multiple pages returned from one request?  I don't see
how to create the multi-part return, when the data comes from multiple
static files:

eg.

request : www.mysite.com/userdir/index.html  When this request comes in and
based on some settings in the authen-db, we need to generate not only the
data from index.html, but also send the file www.mysite.com/core/info.html
which would be opened in another window.

And to make things worse - even though I called index.html in my exaple, I
really need to trigger the second file whenever "ANY" request comes in to
the users directory.  This means it may be a static file, a directory
listing, or dynamic info created by a module.  The last of which is my main
problem.  I am trying to do this without doing a sepate lwp-request, pulling
into a local array and resending - 

If this is my only way then is it worth it?  Wouldn't the performance hit be
quite high?  80-90% of the users would require this second page.  Are there
a better approach?  

I have found the CGI::Push::do_push, but this only works for dynamic data,
or data in a local @array.  Is there a way to tie Apache to CGI::Push, and
let me pass in a uri?  Or have one leg do a lookup_uri($user_request_uri);,
and the other do a static $r->lookup("/file.html"); ?


do_push(-next_page => \&main_request,
             -last_page =>  \&secondary_page,
             -delay => 0.0,
);


sub main_page {
        my($q,$counter) = @_;                          # $q, $counter are
passed in automagically
        return undef if $counter >= 2;                  # second time
through it terminates the loop
        return $r->lookup_uri($user_request_uri);
 }

sub secondary_page {
        my($q,$counter) = @_;
       return $r->lookup_file("/some_file.html");
}



TIA -

Re: ?? Server-push or sending multipart (multiple pages) data to clie nt

Posted by Joe Schaefer <jo...@sunstarsys.com>.
"Lang, Cliff" <cl...@proxicom.com> writes:


[...]

> request : www.mysite.com/userdir/index.html  When this request comes in and
> based on some settings in the authen-db, we need to generate not only the
> data from index.html, but also send the file www.mysite.com/core/info.html
> which would be opened in another window.

Server push has been dead for some time- IE5 doesn't even support the
x-multipart-replace header. The known IE5 "workaround" is to just send 
entire <html>..</html> bodies in sequence w/o additional header info, 
but you probably shouldn't invoke heavy browser voodoo unless you're 
seriously `charmed'.

A lesser (and safer) magic would be to insert a javascript snippet 
in each page. The javascript opens the window and makes the request for 
/core/info.html. Install an appropriate mod_perl content filter for 
"<Location /userdir>" with a line like

s/<body>/<body onLoad='open("/core/info.html", "other_window")'>/io;

Some variation on this might do the trick.

-- 
Joe Schaefer
joe@sunstarsys.com

SunStar Systems, Inc.