Skip to content

Instantly share code, notes, and snippets.

@lsiden
Created May 3, 2010 19:17
Show Gist options
  • Save lsiden/388475 to your computer and use it in GitHub Desktop.
Save lsiden/388475 to your computer and use it in GitHub Desktop.
Submitted to Rack on 3/13/2010
diff -ur rack-rack-39ea53f/lib/rack/content_length.rb rack-1.1.0/lib/rack/content_length.rb
--- rack-rack-39ea53f/lib/rack/content_length.rb 2010-01-03 14:21:42.000000000 -0500
+++ rack-1.1.0/lib/rack/content_length.rb 2010-03-13 20:25:44.000000000 -0500
@@ -13,7 +13,7 @@
status, headers, body = @app.call(env)
headers = HeaderHash.new(headers)
- if !STATUS_WITH_NO_ENTITY_BODY.include?(status) &&
+ if !STATUS_WITH_NO_ENTITY_BODY.include?(status.to_i) &&
!headers['Content-Length'] &&
!headers['Transfer-Encoding'] &&
(body.respond_to?(:to_ary) || body.respond_to?(:to_str))
diff -ur rack-rack-39ea53f/lib/rack/handler/webrick.rb rack-1.1.0/lib/rack/handler/webrick.rb
--- rack-rack-39ea53f/lib/rack/handler/webrick.rb 2010-01-03 14:21:42.000000000 -0500
+++ rack-1.1.0/lib/rack/handler/webrick.rb 2010-03-13 20:35:26.000000000 -0500
@@ -1,10 +1,13 @@
require 'webrick'
require 'stringio'
require 'rack/content_length'
+require 'rack/utils'
module Rack
module Handler
class WEBrick < ::WEBrick::HTTPServlet::AbstractServlet
+ include Rack::Utils
+
def self.run(app, options={})
options[:BindAddress] = options.delete(:Host) if options[:Host]
server = ::WEBrick::HTTPServer.new(options)
@@ -57,9 +60,11 @@
}
end
}
- body.each { |part|
- res.body << part
- }
+ if !STATUS_WITH_NO_ENTITY_BODY.include?(res.status.to_i) then
+ body.each { |part|
+ res.body << part
+ }
+ end
ensure
body.close if body.respond_to? :close
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment