Apache2::REST::Handler::stream


Apache2-REST documentation Contained in the Apache2-REST distribution.

Index


Code Index:

NAME

Apache2::REST::Handler::stream - test handler access '/test/stream' to test a streaming response

GET

Sets the response as a streaming one and returns OK on get.

isAuth

Any method is allowed


Apache2-REST documentation Contained in the Apache2-REST distribution.
package Apache2::REST::Handler::stream ;

use strict ;
use base qw/Apache2::REST::Handler/  ;

use Apache2::REST::Stream::TestStream;

use Apache2::Const qw( 
                       :common :http 
                       );

sub GET{
    my ($self, $req , $resp ) = @_ ;
    
    if ( $req->param('die') ){
        die "This is an error\n" ;
    }
    
    $resp->data()->{'test_mess'} = 'This is a GET test message on a streaming ressource' ;
    $resp->stream(Apache2::REST::Stream::TestStream->new($req->param('chunks') || 10));
    ## It is OK
    return Apache2::Const::HTTP_OK ;
}

sub isAuth{
    my ($self , $method , $req ) = @_ ;
    return 1 ;
}



1;