File: Cat-5.9.patch

package info (click to toggle)
libcatalyst-plugin-subrequest-perl 0.20-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 184 kB
  • ctags: 131
  • sloc: perl: 1,417; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,133 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Description: compatibility with Catalyst 5.9
 Taken from https://gist.github.com/jjn1056/9947765
Author: John Napiorkowski
Bug: https://rt.cpan.org/Public/Bug/Display.html?id=94392
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747502

--- a/lib/Catalyst/Plugin/SubRequest.pm
+++ b/lib/Catalyst/Plugin/SubRequest.pm
@@ -102,18 +102,29 @@ sub sub_request_response {
 
   # need this so that
   my $writer = Catalyst::Plugin::SubRequest::Writer->new;
-  my $response_cb = sub { $writer };
+  my $response_cb = sub {
+    my $response = shift;
+    my ($status, $headers, $body) = @$response;
+    if($body) {
+      return;
+    } else {
+      return $writer;
+    }
+  };
+
   my $i_ctx = $class->prepare( env => $env, response_cb => $response_cb );
   $i_ctx->stash($stash);
   $i_ctx->dispatch;
   $i_ctx->finalize;
   $c->stats->profile( end => 'subrequest: ' . $path ) if $c->debug;
 
-  $i_ctx->response->body($writer->body);
+  if($writer->_is_closed) {
+    $i_ctx->response->body($writer->body);
+  }
 
   return $i_ctx->response;
 }
 
 package Catalyst::Plugin::SubRequest::Writer;
 use Moose;
 has body => (