-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It was there for API compatibility and it is just a subset of OutputEnumerator anyway
- Loading branch information
Showing
13 changed files
with
362 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# A body wrapper that emits chunked responses, creating valid | ||
# Transfer-Encoding::Chunked HTTP response body. This is copied from Rack::Chunked::Body, | ||
# because Rack is not going to include that class after version 3.x | ||
# Rails has a substitute class for this inside ActionController::Streaming, | ||
# but that module is a private constant in the Rails codebase, and is thus | ||
# considered "private" from the Rails standpoint. It is not that much code to | ||
# carry, so we copy it into our code. | ||
class ZipKit::RackChunkedBody | ||
TERM = "\r\n" | ||
TAIL = "0#{TERM}" | ||
|
||
# @param body[#each] the enumerable that yields bytes, usually a `OutputEnumerator` | ||
def initialize(body) | ||
@body = body | ||
end | ||
|
||
# For each string yielded by the response body, yield | ||
# the element in chunked encoding - and finish off with a terminator | ||
def each | ||
term = TERM | ||
@body.each do |chunk| | ||
size = chunk.bytesize | ||
next if size == 0 | ||
|
||
yield [size.to_s(16), term, chunk.b, term].join | ||
end | ||
yield TAIL | ||
yield term | ||
end | ||
end |
Oops, something went wrong.