about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-06-27 23:36:51 +0000
committerEric Wong <normalperson@yhbt.net>2010-06-27 23:36:51 +0000
commit43745f26e201655f98351684e1d357cbd8c15b05 (patch)
tree98c2136d9a2b0419b68b2d707e8da3aa6780c0ce
parent4442a5f7d517645957d5a78911fec48010d3e6c7 (diff)
downloadrainbows-43745f26e201655f98351684e1d357cbd8c15b05.tar.gz
No point in documenting our internals and overwhelming
users.
-rw-r--r--lib/rainbows/http_response.rb55
1 files changed, 27 insertions, 28 deletions
diff --git a/lib/rainbows/http_response.rb b/lib/rainbows/http_response.rb
index 1933218..5552c30 100644
--- a/lib/rainbows/http_response.rb
+++ b/lib/rainbows/http_response.rb
@@ -1,38 +1,37 @@
 # -*- encoding: binary -*-
-require 'time'
+require 'time' # for Time#httpdate
 
-module Rainbows
+# :stopdoc:
+class Rainbows::HttpResponse < ::Unicorn::HttpResponse
 
-  class HttpResponse < ::Unicorn::HttpResponse
+  def self.header_string(status, headers, out)
+    status = CODES[status.to_i] || status
 
-    def self.header_string(status, headers, out)
-      status = CODES[status.to_i] || status
-
-      headers.each do |key, value|
-        next if %r{\AX-Rainbows-}i =~ key
-        next if SKIP.include?(key.downcase)
-        if value =~ /\n/
-          # avoiding blank, key-only cookies with /\n+/
-          out.concat(value.split(/\n+/).map! { |v| "#{key}: #{v}\r\n" })
-        else
-          out << "#{key}: #{value}\r\n"
-        end
+    headers.each do |key, value|
+      next if %r{\AX-Rainbows-}i =~ key
+      next if SKIP.include?(key.downcase)
+      if value =~ /\n/
+        # avoiding blank, key-only cookies with /\n+/
+        out.concat(value.split(/\n+/).map! { |v| "#{key}: #{v}\r\n" })
+      else
+        out << "#{key}: #{value}\r\n"
       end
-
-      "HTTP/1.1 #{status}\r\n" \
-      "Date: #{Time.now.httpdate}\r\n" \
-      "Status: #{status}\r\n" \
-      "#{out.join('')}\r\n"
     end
 
-    def self.write(socket, rack_response, out = [])
-      status, headers, body = rack_response
-      out.instance_of?(Array) and
-        socket.write(header_string(status, headers, out))
+    "HTTP/1.1 #{status}\r\n" \
+    "Date: #{Time.now.httpdate}\r\n" \
+    "Status: #{status}\r\n" \
+    "#{out.join('')}\r\n"
+  end
 
-      body.each { |chunk| socket.write(chunk) }
-      ensure
-        body.respond_to?(:close) and body.close
-    end
+  def self.write(socket, rack_response, out = [])
+    status, headers, body = rack_response
+    out.instance_of?(Array) and
+      socket.write(header_string(status, headers, out))
+
+    body.each { |chunk| socket.write(chunk) }
+    ensure
+      body.respond_to?(:close) and body.close
   end
 end
+# :startdoc: