Skip to content

Commit

Permalink
Allow calling close on rack.input.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Aug 29, 2022
1 parent 1a9b98d commit 537914f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -23,6 +23,7 @@ All notable changes to this project will be documented in this file. For info on
- `rack.hijack?` (partial hijack) and `rack.hijack` (full hijack) are now independently optional.
- `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.

### Removed

Expand Down
3 changes: 2 additions & 1 deletion SPEC.rdoc
Expand Up @@ -166,7 +166,8 @@ The input stream must respond to +gets+, +each+, and +read+.
If +buffer+ is given, then the read data will be placed
into +buffer+ instead of a newly created String object.
* +each+ must be called without arguments and only yield Strings.
* +close+ must never be called on the input stream.
* +close+ can be called on the input stream to indicate that the
any remaining input is not needed.

=== The Error Stream

Expand Down
5 changes: 3 additions & 2 deletions lib/rack/lint.rb
Expand Up @@ -478,9 +478,10 @@ def each(*args)
}
end

## * +close+ must never be called on the input stream.
## * +close+ can be called on the input stream to indicate that the
## any remaining input is not needed.
def close(*args)
raise LintError, "rack.input#close must not be called"
@input.close(*args)
end
end

Expand Down

0 comments on commit 537914f

Please sign in to comment.