I assume you are running this script under Apache::Registry (since your URLs have .pl extensions). Apache::Registry compiles your code into a subroutine and runs it using this code:
my $old_status = $r->status; my $cv = \&{"$package\::handler"}; eval { &{$cv}($r, @_) } if $r->seqno; ... snip ... return $r->status($old_status); Notice that it throws away the result of the eval {}, so it doesn't really matter what you return. However, you can use $r->status from your script to set the status code. Apache::Registry will return the value you set via $r->status from it's handler() method. (I'm not sure why it's trying to set $old_status at the same time. If you look at the XS code it's clear that $r->status returns the previously set value. Anybody know the reason?) Also, Apache will call send_error_response for all 204, 3xx, 4xx, and 5xx status codes. So, you shouldn't call send_http_header in these cases. Finally, you probably also want to set the Last-Modified header for HTTP/1.0 clients that don't understand ETag headers. You can use $r->update_mtime and $r->set_last_modified. So, try the following change to your code: $R->content_type ($data {mimetype}); $R->set_content_length ($data {size}); $R->header_out ('ETag',$data {md5}); $R->update_mtime($data {mtime}); $R->set_last_modified; if ((my $rc = $R->meets_conditions) != OK) { $R->status($rc); return; } $R->send_http_header; unless($R->header_only) { print $file->get ('data'); } -- Kyle Oppenheim Tellme Networks, Inc. http://www.tellme.com > -----Original Message----- > From: Cristóvão Dalla Costa [mailto:cbraga@;bsi.com.br] > Sent: Friday, October 25, 2002 4:31 PM > To: [EMAIL PROTECTED] > Subject: conditional get > > > Hi, I'm trying to get my script to work with conditional get, however, > when the browser should use the local copy it doesn't display anything, > just telling me that the image's broken. I get the image from a > database, the snippet that sends it is this: > > $R->content_type ($data {mimetype}); > $R->set_content_length ($data {size}); > $R->header_out ('ETag',$data {md5}); > $R->send_http_header; > > return OK () if ($R->header_only); > > if ((my $rc = $R->meets_conditions) != OK) { > return $rc; > } > > print $file->get ('data'); > > If I comment out $R->send_http_header, the apache logs show full size > for the request that doesn't meet conditions, otherwise it shows 0 > bytes. In both cases, when supposedly serving from its cache, the > browser hangs for a few seconds. > > The logs look like these; the first line is for a request that meets > conditions, the second for one that does not. > > 192.168.255.2 - - [25/Oct/2002:21:21:43 -0200] "GET /binfile.pl?id=32 > HTTP/1.1" 200 148087 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; > en-US; rv:1.2b) Gecko/20021016" > > 192.168.255.2 - - [25/Oct/2002:21:25:28 -0200] "GET /binfile.pl?id=32 > HTTP/1.1" 200 - "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; > rv:1.2b) Gecko/20021016" > > If I comment out the last return, it works perfectly. I copied the code > from mod_perl's docs, from the section about correct headers. > > Thanks in advance. > > Cristóvão > >