Created
June 30, 2020 13:48
-
-
Save aquaflamingo/9e15923d82b8b619df3f3485c72fdfa8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Generate a response array consistent with the requirements of the SPEC. | |
# @return [Array] a 3-tuple suitable of `[status, headers, body]` | |
# which is suitable to be returned from the middleware `#call(env)` method. | |
def finish(&block) | |
if STATUS_WITH_NO_ENTITY_BODY[status.to_i] | |
delete_header CONTENT_TYPE | |
delete_header CONTENT_LENGTH | |
close | |
return [@status, @headers, []] | |
else | |
if block_given? | |
@block = block | |
return [@status, @headers, self] | |
else | |
return [@status, @headers, @body] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment