On 11/12/2012 06:19 PM, André Warnier wrote: > In response to some request URLs, I have to compose a response > structured as follows : > > - a html frameset document with two frames > - in the 1st frame, the result of another HTTP request to the same > Apache server. > This URI of this HTTP request is created by "mangling" the original > request URL somewhat. > - in the 2d frame, the content of the HTML file corresponding to the > original request URI. > > For example, if the original request URI was something like : > "/abc/def/ghi.html", then > - the top frame should contain the (html) output of a request to > "/cgi-bin/mangle.pl?arg=ghi" > - the bottom frame should contain the content of the > originally-requested "/abc/def/ghi.html" URI (which is a static file). > > I am thinking of doing this by : > - creating a mod_perl ResponseHandler > - having this response handler make a first sub-request to the > "/cgi-bin/mangle.pl?arg=ghi" URI, grabbing the content of the response > to that sub-request, and insert it into the first <frame> of the output > <frameset> document. > - having the response handler do a lookup_uri of the original URI, get > the resulting filename, reading the file and insert its content into the > second <frame> of the output <frameset> document. > > My 1st question is : is the above a valid plan, or is there something > fundamentally wrong with this approach ? > > My 2d question is : looking at the Apache2::SubRequest documentation, I > do not see a clear way of getting the response content of a subrequest. > For example, the run() method explanation seems to indicate that the > response content is sent directly to the client. > Am I missing something ?
I don't really understand what you want to achieve. But if you just want to insert a header on top of each page, this can be done without a frameset (you know, they are utterly deprecated). Use a PerlOutputFilterHandler to insert a <div> or perhaps even an <iframe> just after the opening <body> tag. Once you have found the <body> tag in the output stream, you pass it further down the filter chain and add perhaps the opening <div>. Then you create and run the subrequest. Then you put out the rest of the brigade, remove the filter and return. Thus, the filter will probably be called only once because the <body> tag tends to appear within the first few kbytes of the document. If that is the case, you can even adjust the Content-Length header properly to include the additional stuff. Otherwise you should remove the Content-Length header. Things you have to consider: - filtering data costs CPU cylces This is especially true if you served just plain files before by sendfile(2). - on the other hand, you can put mod_cache in front of those requests (even in the same apache) and they will be served even faster than the plain files before - deleting the Content-Length header is to be avoided if possible. It increases the overall transfer time considerably - if you have used precompressed plain files before they are now useless. Instead you'll have to use the DEFLATE filter. This costs additional CPU cycles. But again mod_cache helps a lot. One other idea comes to mind. If you want to stick with your frameset but prevent multiple requests perhaps you can use "data:" URLs as src. This probably requires much more complicated filtering. Torsten