Skip Menu |
 

This queue is for tickets about the HTTP-Proxy CPAN distribution.

Report information
The Basics
Id: 11480
Status: new
Priority: 0/
Queue: HTTP-Proxy

People
Owner: Nobody in particular
Requestors: jtobey [...] john-edwin-tobey.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 0.13
Fixed in: (no value)

Attachments


Subject: $response->content(\&coderef)
Download (untitled) / with headers
text/plain 578b
Many thanks for the wonderful module! With this patch (see rt.cpan.org) to HTTP/Proxy.pm 0.13, request filters can use coderefs in short-circuiting responses, as with HTTP::Daemon. This makes it easy to serve a large response locally without reading it all into memory. It may also allow one to reuse code that relies on the HTTP::Daemon feature. One could argue that the problem is in HTTP::Daemon. A better solution might be to split HTTP::Daemon::send_response into header and body portions so that users would have less need to duplicate its logic. Best regards, -John
Download proxy.diff
text/x-diff 1k
--- /usr/local/share/perl/5.6.1/HTTP/Proxy.pm Tue Mar 2 19:15:02 2004 +++ /home/jtobey/lib/perl/HTTP/Proxy.pm Sat Feb 12 12:13:28 2005 @@ -621,7 +621,18 @@ if ( !$sent ) { ($last, $chunked) = $self->_send_response_headers( $served ); my $content = $response->content; - if ($chunked) { + if (ref($content) eq "CODE") { + while (1) { + my $chunk = &$content(); + last unless defined($chunk) && length($chunk); + if ($chunked) { + printf $conn "%x$CRLF%s$CRLF", length($chunk), $chunk; + } else { + print $conn $chunk; + } + } + print $conn "0$CRLF$CRLF" if $chunked; # no trailers either + } elsif ($chunked) { printf $conn "%x$CRLF%s$CRLF", length($content), $content if length($content); # the filter may leave nothing print $conn "0$CRLF$CRLF";


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.