perl-modperl mailing list archives

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

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
Apache2::Const::HTTP_PARTIAL_CONTENT.]
This gives a http status code of 200 and internal error message in the
server.

http://perl.apache.org/docs/2.0/user/coding/cooking.html#Sending_Cookies_in_REDIRECT_Response__ModPerl__Registry_



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


Thanx,
HB.
----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->content_type('audio/mpeg');
        $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' );
        $r->print('ZZ');
        return Apache2::Const::OK;

Mime
View raw message