http://www.perlmonks.org?node_id=1033563


in reply to Re^2: Dancer as a proxy
in thread Dancer as a proxy

Thank you Anonymous Monk! I did need to change it a bit to make it work as I was having issues getting the headers information and things appear to working rather nicely now.

For future reference, and in case others find it useful, the modified send_file is:

return send_file( \'fake contents to be replaced in override', streaming => 1, callbacks => { override => sub { eval { my ( $respond, $response ) = @_; require LWP; my $ua = LWP::UserAgent->new; my $writer ; $ua->get( $new_route, ':content_cb' => sub { my ( $data, $response, $protocol ) = @_; if(not $writer ){ my $h = $response->headers ; my %m = map {$_ => $h->header($_)} ('Content-Length', 'Content-Type', 'Last-Modified' +); $writer = $respond->( [ $response->code, [ %m ] ] ); } $writer->write( $data ); }, ## end of :content_cb ); ## end of $ua->get } or Dancer::Logger::error("stream-file: bad eval $@"); return; }, ## end of override }, ); ## end of send_file