diff --git a/lib/puma/const.rb b/lib/puma/const.rb index f10c27da..7a7ca815 100644 --- a/lib/puma/const.rb +++ b/lib/puma/const.rb @@ -1,5 +1,3 @@ -require 'set' - module Puma # Every standard HTTP code mapped to the appropriate message. These are @@ -46,7 +44,9 @@ module Puma } # For some HTTP status codes the client only expects headers. - STATUS_WITH_NO_ENTITY_BODY = Set.new((100..199).to_a << 204 << 205 << 304) + STATUS_WITH_NO_ENTITY_BODY = { + 204 => true, 205 => true, 304 => true + } # Frequently used constants when constructing requests or responses. Many times # the constant just refers to a string with the same contents. Using these constants diff --git a/lib/puma/server.rb b/lib/puma/server.rb index e18b3c80..03a6f618 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -341,7 +341,7 @@ module Puma end content_length = nil - no_body = STATUS_WITH_NO_ENTITY_BODY.include? status + no_body = false if res_body.kind_of? Array and res_body.size == 1 content_length = res_body[0].size @@ -366,6 +366,8 @@ module Puma client.write " " client.write HTTP_STATUS_CODES[status] client.write "\r\n" + + no_body = status < 200 || STATUS_WITH_NO_ENTITY_BODY[status] end else allow_chunked = false @@ -382,6 +384,8 @@ module Puma client.write " " client.write HTTP_STATUS_CODES[status] client.write "\r\n" + + no_body = status < 200 || STATUS_WITH_NO_ENTITY_BODY[status] end end