{package HTTP::Proxy::ContentRange; use base HTTP::Proxy; use HTTP::Proxy::HeaderFilter::contentrange; use HTTP::Proxy::BodyFilter::complete; use HTTP::Proxy::BodyFilter::contentRange; use strict; sub new { my $class = shift; my $self = SUPER::new(@_); # Whe depend on HPB::complete. $self->push_filter( response => HTTP::Proxy::HeaderFilter::contentrange->new, response => HTTP::Proxy::BodyFilter::complete->new, response => HTTP::Proxy::BodyFilter::contentRange->new); return $self; } #### {package HTTP::Proxy::HeaderFilter::contentrange; use HTTP::Proxy; use base HTTP::Proxy::HeaderFilter; use strict; sub filter(){ my ( $self, $headers, $message) = @_; if ( $message->isa('HTTP::Response') and $message->code == 200 and $range = $message->request->header('Content-Range') ){ #Let's fix that nasty behaviour! ;-) $message->code(206); $message->header('Content-Range' => $range); #XXX: Find a way to calc content-lenght $message->remove_header('Content-Length'); #Mark this for body processing! $self->SUPER::proxy->stash($message->uri => 1); } } 1; } #### {package HTTP::Proxy::BodyFilter::contentRange; use HTTP::Proxy; use base HTTP::Proxy::BodyFilter; use strict; use base HTTP::Proxy::BodyFilter; } sub filter{ my ($self, $dataref, $message, $protocol, $buffer) = @_; #Was this response marked for processing? if ( SUPER::proxy->stash($message->uri) == 1 ){ ###### # TO IMPLEMENT # Parse Content-Range and select data to send. ###### #XXX: Wouldn't be wise to save content to a temp file and avoid # filling up memory. Maybe use HPB::save? #Delete entry from process table delete SUPER->proxy->stash{$message->uri}; } } 1; }