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
Fix errors when setting nil headers or values on responses
tmm1 (author)
Fri Jul 25 12:55:25 -0700 2008
commit  8843e4abb7b7f2f91e4c3f830422646e67a414c2
tree    f3019995f3149353194de2e25a7abef2942eeafa
parent  a8a71b8770bcefe38daecd3be903846084c60051
...
44
45
46
47
48
 
 
49
50
51
...
57
58
59
 
60
61
62
63
64
65
66
 
 
67
68
69
...
44
45
46
 
 
47
48
49
50
51
...
57
58
59
60
61
62
63
64
65
 
 
66
67
68
69
70
0
@@ -44,8 +44,8 @@ module Thin
0
       # Respects Rack specs.
0
       def headers=(key_value_pairs)
0
         key_value_pairs.each do |k, vs|
0
- vs.each { |v| @headers[k] = v.chomp }
0
- end
0
+ vs.each { |v| @headers[k] = v.chomp } if vs
0
+ end if key_value_pairs
0
       end
0
 
0
     else
0
@@ -57,13 +57,14 @@ module Thin
0
       # To be reviewed when a new Rack spec comes out.
0
       def headers=(key_value_pairs)
0
         key_value_pairs.each do |k, vs|
0
+ next unless vs
0
           if vs.is_a?(String)
0
             vs.each_line { |v| @headers[k] = v.chomp }
0
           else
0
             vs.each { |v| @headers[k] = v.chomp }
0
           end
0
- end
0
- end
0
+ end if key_value_pairs
0
+ end
0
 
0
     end
0
     
...
43
44
45
 
 
 
 
 
 
 
46
47
48
...
43
44
45
46
47
48
49
50
51
52
53
54
55
0
@@ -43,6 +43,13 @@ describe Response do
0
     
0
     @response.head.should include("Set-Cookie: mium=7", "Set-Cookie: hi=there")
0
   end
0
+
0
+ it 'should ignore nil headers' do
0
+ @response.headers = nil
0
+ @response.headers = { 'Host' => 'localhost' }
0
+ @response.headers = { 'Set-Cookie' => nil }
0
+ @response.head.should include('Host: localhost')
0
+ end
0
   
0
   it 'should output body' do
0
     @response.body = '<html></html>'

Comments

    No one has commented yet.