Skip to content

Instantly share code, notes, and snippets.

@aquaflamingo
Created June 30, 2020 13:48
Show Gist options
  • Save aquaflamingo/9e15923d82b8b619df3f3485c72fdfa8 to your computer and use it in GitHub Desktop.
Save aquaflamingo/9e15923d82b8b619df3f3485c72fdfa8 to your computer and use it in GitHub Desktop.
# 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