summaryrefslogtreecommitdiffstats
path: root/rubygem-actionpack-2.3.5-rack-compat.patch
blob: 5e6451f6f72a2ca0805b3fa151bb73414aae5eb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
--- Rakefile.debug	2010-01-07 03:03:57.000000000 +0900
+++ Rakefile	2010-01-28 00:43:00.000000000 +0900
@@ -80,7 +80,7 @@
   s.requirements << 'none'
 
   s.add_dependency('activesupport', '= 2.3.5' + PKG_BUILD)
-  s.add_dependency('rack', '~> 1.0.0')
+  s.add_dependency('rack', '>= 1.0.0')
 
   s.require_path = 'lib'
   s.autorequire = 'action_controller'
--- lib/action_controller.rb.debug	2010-01-07 03:03:57.000000000 +0900
+++ lib/action_controller.rb	2010-01-28 00:43:00.000000000 +0900
@@ -31,7 +31,7 @@
   end
 end
 
-gem 'rack', '~> 1.0.1'
+gem 'rack', '>= 1.0.1'
 require 'rack'
 require 'action_controller/cgi_ext'
 
--- lib/action_controller/integration.rb.debug	2010-01-07 03:03:57.000000000 +0900
+++ lib/action_controller/integration.rb	2010-01-07 18:46:03.000000000 +0900
@@ -320,9 +320,25 @@
 
           @headers = Rack::Utils::HeaderHash.new(headers)
 
-          (@headers['Set-Cookie'] || "").split("\n").each do |cookie|
-            name, value = cookie.match(/^([^=]*)=([^;]*);/)[1,2]
-            @cookies[name] = value
+          # Umm.. it seems that with rack 1.1.0 @headers is an array
+          # instead of a string which rack 1.0.0 returned
+          # FIXME!!
+
+          headers_cookie = @headers['Set-Cookie']
+          if headers_cookie.is_a?(Array)
+              headers_cookie.each do |cookie_arr|
+                cookie_arr.split("\n").each do |cookie|
+                  name, value = cookie.match(/^([^=]*)=([^;]*);/)[1,2]
+                  @cookies[name] = value
+                end
+              end
+
+          else
+
+            (headers_cookie || "").split("\n").each do |cookie|
+              name, value = cookie.match(/^([^=]*)=([^;]*);/)[1,2]
+              @cookies[name] = value
+            end
           end
 
           @body = ""
--- lib/action_controller/response.rb.debug	2010-01-07 03:03:57.000000000 +0900
+++ lib/action_controller/response.rb	2010-01-07 19:40:44.000000000 +0900
@@ -112,6 +112,12 @@
     end
 
     def etag?
+
+      # FIXME!!
+      if Rack::VERSION[0] == 1 && Rack::VERSION[1] >= 1
+        return headers.include?('ETag') && !headers['ETag'].nil?
+      end
+
       headers.include?('ETag')
     end
 
@@ -218,8 +224,15 @@
       # Don't set the Content-Length for block-based bodies as that would mean
       # reading it all into memory. Not nice for, say, a 2GB streaming file.
       def set_content_length!
+
+        ## FIXME
+
         if status && status.to_s[0..2] == '204'
           headers.delete('Content-Length')
+
+        elsif Rack::VERSION[0] == 1 && Rack::VERSION[1] >= 1 && status && status.to_s[0..2] == '304'
+          headers.delete('Content-Length')
+
         elsif length = headers['Content-Length']
           headers['Content-Length'] = length.to_s
         elsif !body.respond_to?(:call) && (!status || status.to_s[0..2] != '304')
--- test/controller/integration_test.rb.debug	2010-01-07 03:03:57.000000000 +0900
+++ test/controller/integration_test.rb	2010-01-07 05:44:37.000000000 +0900
@@ -306,7 +306,9 @@
       assert_equal "Gone", status_message
       assert_response 410
       assert_response :gone
-      assert_equal "cookie_1=; path=/\ncookie_3=chocolate; path=/", headers["Set-Cookie"]
+      # Okay if cookies coincides.
+      # With rake 1.1.0 headers["Set-Cookie"] is an array instread of a string
+      #assert_equal "cookie_1=; path=/\ncookie_3=chocolate; path=/", headers["Set-Cookie"]
       assert_equal({"cookie_1"=>"", "cookie_2"=>"oatmeal", "cookie_3"=>"chocolate"}, cookies)
       assert_equal "Gone", response.body
     end
--- test/controller/rack_test.rb.debug	2010-01-07 03:03:57.000000000 +0900
+++ test/controller/rack_test.rb	2010-01-07 05:40:49.000000000 +0900
@@ -215,11 +215,16 @@
 
     status, headers, body = @response.to_a
     assert_equal 200, status
+    if headers['Set-Cookie'].is_a?(Array)
+      cookie_must = []
+    else
+      cookie_must = ""
+    end
     assert_equal({
       "Content-Type" => "text/html; charset=utf-8",
       "Cache-Control" => "private, max-age=0, must-revalidate",
       "ETag" => '"65a8e27d8879283831b664bd8b7f0ad4"',
-      "Set-Cookie" => "",
+      "Set-Cookie" => cookie_must,
       "Content-Length" => "13"
     }, headers)
 
@@ -234,11 +239,16 @@
 
     status, headers, body = @response.to_a
     assert_equal 200, status
+    if headers['Set-Cookie'].is_a?(Array)
+      cookie_must = []
+    else
+      cookie_must = ""
+    end
     assert_equal({
       "Content-Type" => "text/html; charset=utf-8",
       "Cache-Control" => "private, max-age=0, must-revalidate",
       "ETag" => '"ebb5e89e8a94e9dd22abf5d915d112b2"',
-      "Set-Cookie" => "",
+      "Set-Cookie" => cookie_must,
       "Content-Length" => "8"
     }, headers)
   end
@@ -251,10 +261,15 @@
 
     status, headers, body = @response.to_a
     assert_equal 200, status
+    if headers['Set-Cookie'].is_a?(Array)
+      cookie_must = []
+    else
+      cookie_must = ""
+    end
     assert_equal({
       "Content-Type" => "text/html; charset=utf-8",
       "Cache-Control" => "no-cache",
-      "Set-Cookie" => ""
+      "Set-Cookie" => cookie_must
     }, headers)
 
     parts = []
--- test/controller/session/cookie_store_test.rb.debug	2010-01-07 03:03:57.000000000 +0900
+++ test/controller/session/cookie_store_test.rb	2010-01-07 05:47:37.000000000 +0900
@@ -145,7 +145,8 @@
     with_test_route_set do
       get '/no_session_access'
       assert_response :success
-      assert_equal "", headers['Set-Cookie']
+      #assert_equal "", headers['Set-Cookie']
+      assert headers['Set-Cookie'].empty?
     end
   end
 
@@ -155,7 +156,8 @@
         "fef868465920f415f2c0652d6910d3af288a0367"
       get '/no_session_access'
       assert_response :success
-      assert_equal "", headers['Set-Cookie']
+      #assert_equal "", headers['Set-Cookie']
+      assert headers['Set-Cookie'].empty?
     end
   end