Skip to content
Browse files

Merged pull request #251 from nusco/master.

Leave removing the body of a HEAD request to Rack::Head
  • Loading branch information...
2 parents 19a59ea + 2509680 commit 02d746dcb449504a6d18a01d17e45f6e070d8a5e @rkh rkh committed Apr 26, 2011
Showing with 2 additions and 11 deletions.
  1. +2 −11 lib/sinatra/base.rb
View
13 lib/sinatra/base.rb
@@ -652,17 +652,7 @@ def call!(env) # :nodoc:
end
end
- status, header, body = @response.finish
-
- # Never produce a body on HEAD requests. Do retain the Content-Length
- # unless it's "0", in which case we assume it was calculated erroneously
- # for a manual HEAD response and remove it entirely.
- if @env['REQUEST_METHOD'] == 'HEAD'
- body = []
- header.delete('Content-Length') if header['Content-Length'] == '0'
- end
-
- [status, header, body]
+ @response.finish
end
# Access settings defined with Base.set.
@@ -1272,6 +1262,7 @@ def build(*args, &bk)
builder = Rack::Builder.new
builder.use Rack::MethodOverride if method_override?
builder.use ShowExceptions if show_exceptions?
+ builder.use Rack::Head
setup_logging builder
setup_sessions builder
middleware.each { |c,a,b| builder.use(c, *a, &b) }

0 comments on commit 02d746d

Please sign in to comment.
Something went wrong with that request. Please try again.