perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hemant Bist" <>
Subject Correct way to send http status code 206 -Partial content?
Date Fri, 28 Dec 2007 22:53:55 GMT

What is the correct way to send http status code of 206 from from Modperl
Registry script [In modperl2/apache2]? I searched the modperl site but did
not find any examples.

I looked at the following redirect example [by setting
$r->status(Apache2::Const::HTTP_PARTIAL_CONTENT) and returning
This gives a http status code of 200 and internal error message in the

OK, after a while, I also tried setting $r->statusline( ) and this seems to
work, but I am not sure if this the right way. I am pasting a sample code
that works correctly

----Sample code that works fine ----

use Apache2::Request;
use Apache2::RequestUtil;
use Data::Dumper;
use Apache2::Const -compile => qw(HTTP_PARTIAL_CONTENT OK HTTP_OK);
use APR::Table ();
use strict;
use constant MOD_PERL => $ENV{MOD_PERL};

        my $r = shift;
        $r->headers_out->set('Accept-Ranges'=> 'bytes');
        $r->headers_out->set('Content-Length' => 2);
        $r->headers_out->set('Content-Range' => 'bytes 0-1/40000');
        $r->status_line(Apache2::Const::HTTP_PARTIAL_CONTENT. ' Partial
Content' );
        return Apache2::Const::OK;

View raw message