PerlDancer / Dancer2

Perl Dancer Next Generation (rewrite of Perl Dancer)
http://perldancer.org/
Other
543 stars 273 forks source link

BUG: missing push_header method in Response::Delayed #1578

Closed clemep-sios closed 3 years ago

clemep-sios commented 3 years ago

This is a request to fix Response::Delayed to avoid incompatibilities with the base Response type, such as:

[Mon Jan 18 12:11:19 2021] trace: Entering hook core.app.after_request
[Mon Jan 18 12:11:19 2021] error: Exception caught in 'core.app.after_request' filter: Hook error: Can't locate object method "push_header" via package "Dancer2::Core::Response::Delayed" at /root/perl5/lib/perl5/Dancer2/Plugin/JWT.pm line 237.
 at /usr/local/share/perl5/Dancer2/Plugin.pm line 597.
 at /usr/local/share/perl5/Dancer2/Core/Role/Logger.pm line 151

The following simple patch fixes this:

$ diff -pu Delayed.pm{.orig,}
--- Delayed.pm.orig     2021-01-18 12:12:44.320175881 -0500
+++ Delayed.pm  2021-01-18 12:12:04.581015174 -0500
@@ -14,7 +14,7 @@ has response => (
     is       => 'ro',
     isa      => InstanceOf['Dancer2::Core::Response'],
     required => 1,
-    handles => [qw/status headers/],
+    handles => [qw/status headers push_header/],
 );

 has cb => (
cromedome commented 3 years ago

Thanks! I appreciate you finding this and pointing us to a fix!

Any chance I can get this as a PR with a test for the release I am working on?

clemep-sios commented 3 years ago

https://github.com/PerlDancer/Dancer2/pull/1579

Hopefully the tests are in an appropriate place.

cromedome commented 3 years ago

Resolved by #1579. Thank you so much!