public
Fork of macournoyer/thin
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/tmm1/thin.git
Handle nil and Time header values correctly
tmm1 (author)
Fri Jul 25 12:39:11 -0700 2008
commit  a8a71b8770bcefe38daecd3be903846084c60051
tree    890f503c21248114c1697bf530eb3e3ab3268657
parent  b9ec90108045101501a436cb124599d4a70fcbdb
...
3
4
5
 
6
7
8
...
3
4
5
6
7
8
9
0
@@ -3,6 +3,7 @@ $:.unshift File.expand_path(File.dirname(__FILE__))
0
 require 'fileutils'
0
 require 'timeout'
0
 require 'stringio'
0
+require 'time'
0
 
0
 require 'rubygems'
0
 require 'eventmachine'
...
16
17
18
 
 
 
 
 
 
 
 
19
20
21
...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
0
@@ -16,6 +16,14 @@ module Thin
0
     def []=(key, value)
0
       if !@sent.has_key?(key) || ALLOWED_DUPLICATES.include?(key)
0
         @sent[key] = true
0
+ value = case value
0
+ when Time
0
+ value.rfc822
0
+ when NilClass
0
+ return
0
+ else
0
+ value.to_s
0
+ end
0
         @out << HEADER_FORMAT % [key, value]
0
       end
0
     end
...
26
27
28
 
 
 
 
 
 
 
 
 
 
 
29
30
...
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
0
@@ -26,4 +26,15 @@ describe Headers do
0
     
0
     @headers.to_s.should == "Host: localhost:3000\r\nSet-Cookie: twice\r\nSet-Cookie: is cooler the once\r\n"
0
   end
0
+
0
+ it 'should ignore nil values' do
0
+ @headers['Something'] = nil
0
+ @headers.to_s.should_not include('Something: ')
0
+ end
0
+
0
+ it 'should format Time values correctly' do
0
+ time = Time.now
0
+ @headers['Modified-At'] = time
0
+ @headers.to_s.should include("Modified-At: #{time.rfc822}")
0
+ end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.