Geoffrey Young wrote: >>>> unless (exists $ENV{MOD_PERL} >>>> ? Apache2::RequestUtil->request()->bytes_sent() >>>> : tell STDOUT) >>>> { >>>> #... send response headers >>> since you no longer send response headers in mp2, isn't this all >>> moot? >> >> Did you overlook the fact that I'm running all this through >> ModPerl::Registry, or am I overlooking something? > > no, I didn't overlook it. but I did forget you said it was in > mod_cgi-compat mode - I haven't thought in those terms in years :) > > still, you can't bee in full CGI mode if you're making mod_perl API > calls like $r->bytes_sent, in which case...
You're right, it's not full CGI mode--as my original post showed I'm querying $ENV{MOD_PERL} to decide whether to check $r->bytes_sent() or tell(STDOUT). >[...] > so, if you are able to change your > > print "Content-Type: text/html\n\n"; > > and like lines to equivalent mp2 API calls you should be ok. Possibly. I tried changing the code in my original post to: if ($ENV{MOD_PERL}) { Apache2::RequestUtil->request()->content_type('text/html'); } elsif (tell STDOUT == 0) { print qq[Content-Type: text/html\n\n]; } but now when the code has an error I get output like: Connection: close Date: Thu, 02 Aug 2007 18:15:14 GMT Server: Apache/2.2.4 (Win32) mod_perl/2.0.3 Perl/v5.8.8 Content-Type: text/html Client-Date: Thu, 02 Aug 2007 18:15:14 GMT Client-Peer: 10.23.50.54:8088 Client-Response-Num: 1 Client-Transfer-Encoding: chunked Content-Language: en-GB Content-Type: text/html; charset=windows-1252 <HTML> ... so the user still the language and type headers in the browser again. The problem here is that the code has already print()ed the language and type headers, so the above setting of $r->content_type() is too late--it has correctly set the header, but has the effect of demoting the already-printed headers to content! So I actually need to go through all the code and find all the places where headers are output, and change them to just set $r->content_type() and $r->content_language() for $ENV{MOD_PERL}, and only print() the headers when in CGI mode. Tedious, but it should work. > > of course, none of this addresses your original bytes_sent() problem, > but that's probably because I've never seen it used that way, even in > the days of old. You mean you've never looked inside CGI::Carp? ;-)