Add support for rack.response_finished (#3681)#9
Add support for rack.response_finished (#3681)#9MitchLewis930 wants to merge 1 commit intopr_059_beforefrom
rack.response_finished (#3681)#9Conversation
* Add support for `rack.response_finished` It is very similar to `rack.after_reply`, but is part of the Rack spec. It can't just be an alias because the spec state it has to invoke callbacks in reverse order. Fix: puma#3631 Ref: rack/rack#1777 Ref: rack/rack#1802 Co-Authored-By: Robert Laurin <robert.laurin@shopify.com> * request.rb - more rename `e` to `error` changes --------- Co-authored-by: Robert Laurin <robert.laurin@shopify.com> Co-authored-by: MSP-Greg <Greg.mpls@gmail.com>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
User description
PR_059
PR Type
Enhancement
Description
Add support for
rack.response_finishedcallback mechanismImplement reverse-order callback invocation per Rack spec
Pass environment, status, headers, and error to callbacks
Rename exception variable
etoerrorfor clarityDiagram Walkthrough
File Walkthrough
const.rb
Add rack.response_finished constantlib/puma/const.rb
RACK_RESPONSE_FINISHEDconstant definition"rack.response_finished"stringbinder.rb
Initialize rack callback extensions in environmentlib/puma/binder.rb
RACK_AFTER_REPLYandRACK_RESPONSE_FINISHEDto nil indefault environment
request.rb
Implement rack.response_finished callback handlinglib/puma/request.rb
errorvariable initialization to capture exceptions during requesthandling
RACK_RESPONSE_FINISHEDarray in request environmentrack.response_finishedcallbacks
etoerrorthroughout exception handlers forconsistency
test_rack_server.rb
Add tests for rack.response_finished callbacktest/test_rack_server.rb
test_rack_response_finishedtest verifying callbacks invoked inreverse order
test_rack_response_finished_on_errortest verifying error ispassed to callbacks
Puma::LogWriter.nullfor cleanertest output
error parameters