From afa16a91777479350125cdbf4bb72715987cfb5a Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Wed, 31 Aug 2022 12:27:37 +1200 Subject: [PATCH 1/3] The stream argument must implement `#<<`. --- CHANGELOG.md | 1 + SPEC.rdoc | 2 +- lib/rack/lint.rb | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b514ec3b0..07d757db5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ All notable changes to this project will be documented in this file. For info on - `rack.hijack_io` has been removed completely. - `rack.response_finished` is an optional environment key which contains an array of callable objects that must accept `#call(env, status, headers, error)` and are invoked after the response is finished (either successfully or unsucessfully). - It is okay to call `#close` on `rack.input` to indicate that you no longer need or care about the input. +- The stream argument to streaming responses and hijack must support `#<<` for writing output. ### Removed diff --git a/SPEC.rdoc b/SPEC.rdoc index 48cd99d66..ddf474ae1 100644 --- a/SPEC.rdoc +++ b/SPEC.rdoc @@ -327,7 +327,7 @@ It must not be called after being closed. It takes a +stream+ argument. The +stream+ argument must implement: -read, write, flush, close, close_read, close_write, closed? +read, write, <<, flush, close, close_read, close_write, closed? The semantics of these IO methods must be a best effort match to those of a normal Ruby IO or Socket object, using standard arguments diff --git a/lib/rack/lint.rb b/lib/rack/lint.rb index 547e6a1c2..42878879a 100755 --- a/lib/rack/lint.rb +++ b/lib/rack/lint.rb @@ -861,7 +861,7 @@ def call(stream) ## It takes a +stream+ argument. ## ## The +stream+ argument must implement: - ## read, write, flush, close, close_read, close_write, closed? + ## read, write, <<, flush, close, close_read, close_write, closed? ## @body.call(StreamWrapper.new(stream)) end @@ -875,7 +875,7 @@ class StreamWrapper ## pass on real IO objects, although it is recognized that this approach ## is not directly compatible with HTTP/2. REQUIRED_METHODS = [ - :read, :write, :flush, :close, + :read, :write, :<<, :flush, :close, :close_read, :close_write, :closed? ] From 9103f4fc50cfb4dee8e4bb3c845ecad8abd9a2d4 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Wed, 31 Aug 2022 14:29:05 +1200 Subject: [PATCH 2/3] Update CHANGELOG. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07d757db5..77c99dd6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ All notable changes to this project will be documented in this file. For info on - Support callable body for explicit streaming support and clarify streaming response body behaviour. ([#1745](https://github.com/rack/rack/pull/1745), [@ioquatix], [#1748](https://github.com/rack/rack/pull/1748), [@wjordan]) - Allow `Rack::Builder#run` to take a block instead of an argument. ([#1942](https://github.com/rack/rack/pull/1942), [@ioquatix]) - Add `rack.response_finished` to `Rack::Lint`. ([#1802](https://github.com/rack/rack/pull/1802), [@BlakeWilliams], [#1952](https://github.com/rack/rack/pull/1952), [@ioquatix]) +- The stream argument must implement `#<<`. ([#1959](https://github.com/rack/rack/pull/1959), [@ioquatix]) ### Changed From 6c7e3be5ae80e1936584bf8ff67878725951b4b6 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Wed, 31 Aug 2022 14:30:52 +1200 Subject: [PATCH 3/3] Update CHANGELOG. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77c99dd6b..daca02c52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ All notable changes to this project will be documented in this file. For info on - `rack.hijack_io` has been removed completely. - `rack.response_finished` is an optional environment key which contains an array of callable objects that must accept `#call(env, status, headers, error)` and are invoked after the response is finished (either successfully or unsucessfully). - It is okay to call `#close` on `rack.input` to indicate that you no longer need or care about the input. -- The stream argument to streaming responses and hijack must support `#<<` for writing output. +- The stream argument supplied to the streaming body and hijack must support `#<<` for writing output. ### Removed