summary refs log tree commit
diff options
context:
space:
mode:
authorDan Kubb <dan.kubb@autopilotmarketing.com>2008-12-20 13:06:28 -0800
committerDan Kubb <dan.kubb@autopilotmarketing.com>2008-12-20 13:06:28 -0800
commit77725c7dafeb242ff6f08c68a811551aec74f182 (patch)
treeb09d7be7a49df19cb8782c52f69cee36facf533f
parent3b116580c6c3b6d1345019541e2895755615165c (diff)
downloadrack-77725c7dafeb242ff6f08c68a811551aec74f182.tar.gz
Moved STATUS_WITH_NO_ENTITY_BODY into Rack::Utils
* Removed duplicate constant from Rack::ContentLength and Rack::Lint
-rw-r--r--lib/rack/content_length.rb4
-rw-r--r--lib/rack/lint.rb10
-rw-r--r--lib/rack/utils.rb3
3 files changed, 8 insertions, 9 deletions
diff --git a/lib/rack/content_length.rb b/lib/rack/content_length.rb
index 3ba7b728..9b21d59d 100644
--- a/lib/rack/content_length.rb
+++ b/lib/rack/content_length.rb
@@ -1,8 +1,6 @@
 module Rack
   # Automatically sets the Content-Length header on all String bodies
   class ContentLength
-    STATUS_WITH_NO_ENTITY_BODY = (100..199).to_a << 204 << 304
-
     def initialize(app)
       @app = app
     end
@@ -10,7 +8,7 @@ module Rack
     def call(env)
       status, headers, body = @app.call(env)
 
-      if !STATUS_WITH_NO_ENTITY_BODY.include?(status) &&
+      if !Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include?(status) &&
           !headers['Content-Length']
 
         bytes = 0
diff --git a/lib/rack/lint.rb b/lib/rack/lint.rb
index 9f64ec76..b95f6f18 100644
--- a/lib/rack/lint.rb
+++ b/lib/rack/lint.rb
@@ -3,8 +3,6 @@ module Rack
   # responses according to the Rack spec.
 
   class Lint
-    STATUS_WITH_NO_ENTITY_BODY = (100..199).to_a << 204 << 304
-
     def initialize(app)
       @app = app
     end
@@ -359,13 +357,13 @@ module Rack
         ## given.
         if key.downcase == "content-type"
           assert("Content-Type header found in #{status} response, not allowed") {
-            not STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
+            not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
           }
           return
         end
       }
       assert("No Content-Type header found") {
-        STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
+        Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
       }
     end
 
@@ -384,7 +382,7 @@ module Rack
           ## +Status+ is 1xx, 204 or 304, in which case there must be none
           ## given.
           assert("Content-Length header found in #{status} response, not allowed") {
-            not STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
+            not Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
           }
 
           assert('Content-Length header should not be used if body is chunked') {
@@ -421,7 +419,7 @@ module Rack
 
       if [ String, Array ].include?(@body.class) && !chunked_response
         assert('No Content-Length header found') {
-          STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
+          Rack::Utils::STATUS_WITH_NO_ENTITY_BODY.include? status.to_i
         }
       end
     end
diff --git a/lib/rack/utils.rb b/lib/rack/utils.rb
index 4fc96b0b..2bb43753 100644
--- a/lib/rack/utils.rb
+++ b/lib/rack/utils.rb
@@ -223,6 +223,9 @@ module Rack
       505  => 'HTTP Version Not Supported'
     }
 
+    # Responses with HTTP status codes that should not have an entity body
+    STATUS_WITH_NO_ENTITY_BODY = (100..199).to_a << 204 << 304
+
     # A multipart form data parser, adapted from IOWA.
     #
     # Usually, Rack::Request#POST takes care of calling this.