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

Owner: Nobody in particular
Requestors: jtobey [...]

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


Subject: $response->content(\&coderef)
Download (untitled) / with headers
text/plain 578b
Many thanks for the wonderful module! With this patch (see to HTTP/ 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/ Tue Mar 2 19:15:02 2004 +++ /home/jtobey/lib/perl/HTTP/ 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 infrastructure.

Please report any issues with to