Browse files

Merge pull request #603 from raggi/rack-1.4

Update Sinatra::Response#finish for Rack 1.5
  • Loading branch information...
2 parents 08373e8 + aea6649 commit 3d0cef2ea7248d98bc50359ac0c1ef0978dfe042 @rkh rkh committed Jan 5, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/sinatra/base.rb
View
4 lib/sinatra/base.rb
@@ -76,15 +76,15 @@ def finish
if status.to_i / 100 == 1
headers.delete "Content-Length"
headers.delete "Content-Type"
- elsif Array === body and not [204, 304].include?(status.to_i)
+ elsif Array === body and not [204, 205, 304].include?(status.to_i)
# if some other code has already set Content-Length, don't muck with it
# currently, this would be the static file-handler
headers["Content-Length"] ||= body.inject(0) { |l, p| l + Rack::Utils.bytesize(p) }.to_s
end
# Rack::Response#finish sometimes returns self as response body. We don't want that.
status, headers, result = super
- result = body if result == self
+ result = body if result == self || Rack::BodyProxy === result
[status, headers, result]
end
end

0 comments on commit 3d0cef2

Please sign in to comment.