Hi, Am Sonntag 01 August 2004 18:13 schrieb Stas Bekman: > Does anybody have any statistics on the percentage of HEAD requests vs. > GET? The purpose of HEAD request is not to save your CPU cycles, but to > avoid data transfer which is precisely what Apache 2.0 does, without > making you do the extra work to deal with HEAD requests. > > > also The comment implies, that I get a Content-Length header for a HEAD > > request, if I waste my time and generate the body of the message. I tried > > it and got _no_ Content-Length header! > > > > $apr->content_type($media_type) unless $apr->main; > > if ( $apr->header_only ) { > > $apr->print( ' ' x $size ); # just to see if I got a content-length > > header return DONE; > > } > > > > The only way to get the Content-Length header for a HEAD request is > > > > $apr->headers_out->{'Content-Length'} = $size ; > > $apr->content_type($media_type) unless $apr->main; > > if ( $apr->header_only ) { > > $apr->rflush; > > return DONE; > > } > > > > But I fail to see why this works, I thought the data walks the same > > filter chain only in more buckets. > > In dynamic scripts you never get the C-L header unless you set it > explicitly and some filter doesn't remove it. It's not possible for > Apache to add one, since headers are sent *before* it knows how much > data your handler is going to send. So HEAD or GET, you won't get it.
But my point is, for a HEAD request, there is no data so apache should not touch my content-length header. I really dislike to generate the full data for the request and apache throws it away ( and even the I get no Content-Length header ). > > So HEAD on dynamic scripts that doesn't set their own C-L is a wasted > operation on behalf of the client. Unless you use some E-Tag (but I > haven't checked the RFC). > > BTW, what's wrong with $r->set_content_length()? Nothing, I searched for the function, but I did not find it! I know I should use mp2doc, but as I searched for it, I did not think on the tool. I tryed first with perldoc Apache::RequestRec and then I searched http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html For some reason I thought if there is no function content_length then I have no function like this. > http://perl.apache.org/docs/2.0/api/Apache/Response.html#C_set_content_leng >th_ Neither you need to rflush. Neither you should return DONE, but OK. I tried it now and even with set_content_length and return OK I got no content-length header. PS: Much thanks for the pointer to Apache::Response, I found more functions that I missed already! -- Boris -- Report problems: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html List etiquette: http://perl.apache.org/maillist/email-etiquette.html