Skip to content

Commit

Permalink
Update Sinatra::Response#finish for Rack 1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
James Tucker committed Jan 4, 2013
1 parent 08373e8 commit aea6649
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sinatra/base.rb
Expand Up @@ -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
Expand Down

0 comments on commit aea6649

Please sign in to comment.