@@ -36,15 +36,15 @@ def app
36
36
test "serve single source file" do
37
37
get "/assets/foo.js"
38
38
assert_equal 200 , last_response . status
39
- assert_equal "9" , last_response . headers [ 'content-length ' ]
40
- assert_equal "Accept-Encoding" , last_response . headers [ 'vary ' ]
39
+ assert_equal "9" , last_response . headers [ 'Content-Length ' ]
40
+ assert_equal "Accept-Encoding" , last_response . headers [ 'Vary ' ]
41
41
assert_equal "var foo;\n " , last_response . body
42
42
end
43
43
44
44
test "serve single self file" do
45
45
get "/assets/foo.self.js"
46
46
assert_equal 200 , last_response . status
47
- assert_equal "9" , last_response . headers [ 'content-length ' ]
47
+ assert_equal "9" , last_response . headers [ 'Content-Length ' ]
48
48
assert_equal "var foo;\n " , last_response . body
49
49
end
50
50
@@ -64,30 +64,30 @@ def app
64
64
assert_equal 200 , last_response . status
65
65
assert_equal "\n (function() {\n application.boot();\n })();\n " ,
66
66
last_response . body
67
- assert_equal "43" , last_response . headers [ 'content-length ' ]
67
+ assert_equal "43" , last_response . headers [ 'Content-Length ' ]
68
68
end
69
69
70
70
test "serve source with content type headers" do
71
71
get "/assets/application.js"
72
- assert_equal "application/javascript" , last_response . headers [ 'content-type ' ]
72
+ assert_equal "application/javascript" , last_response . headers [ 'Content-Type ' ]
73
73
74
74
get "/assets/bootstrap.css"
75
- assert_equal "text/css; charset=utf-8" , last_response . headers [ 'content-type ' ]
75
+ assert_equal "text/css; charset=utf-8" , last_response . headers [ 'Content-Type ' ]
76
76
end
77
77
78
78
test "serve source with etag headers" do
79
79
digest = @env [ 'application.js' ] . etag
80
80
81
81
get "/assets/application.js"
82
82
assert_equal "\" #{ digest } \" " ,
83
- last_response . headers [ 'etag ' ]
83
+ last_response . headers [ 'ETag ' ]
84
84
end
85
85
86
86
test "not modified partial response when if-none-match etags match" do
87
87
get "/assets/application.js"
88
88
assert_equal 200 , last_response . status
89
89
etag , cache_control , expires , vary = last_response . headers . values_at (
90
- 'etag ' , 'cache-control ' , 'Expires' , 'vary '
90
+ 'ETag ' , 'Cache-Control ' , 'Expires' , 'Vary '
91
91
)
92
92
93
93
assert_nil expires
@@ -97,14 +97,14 @@ def app
97
97
assert_equal 304 , last_response . status
98
98
99
99
# Allow 304 headers
100
- assert_equal cache_control , last_response . headers [ 'cache-control ' ]
101
- assert_equal etag , last_response . headers [ 'etag ' ]
100
+ assert_equal cache_control , last_response . headers [ 'Cache-Control ' ]
101
+ assert_equal etag , last_response . headers [ 'ETag ' ]
102
102
assert_nil last_response . headers [ 'Expires' ]
103
- assert_equal vary , last_response . headers [ 'vary ' ]
103
+ assert_equal vary , last_response . headers [ 'Vary ' ]
104
104
105
105
# Disallowed 304 headers
106
- refute last_response . headers [ 'content-type ' ]
107
- refute last_response . headers [ 'content-length ' ]
106
+ refute last_response . headers [ 'Content-Type ' ]
107
+ refute last_response . headers [ 'Content-Length ' ]
108
108
refute last_response . headers [ 'Content-Encoding' ]
109
109
end
110
110
@@ -113,15 +113,15 @@ def app
113
113
'HTTP_IF_NONE_MATCH' => "nope"
114
114
115
115
assert_equal 200 , last_response . status
116
- assert_equal '"b452c9ae1d5c8d9246653e0d93bc83abce0ee09ef725c0f0a29a41269c217b83"' , last_response . headers [ 'etag ' ]
117
- assert_equal '52' , last_response . headers [ 'content-length ' ]
116
+ assert_equal '"b452c9ae1d5c8d9246653e0d93bc83abce0ee09ef725c0f0a29a41269c217b83"' , last_response . headers [ 'ETag ' ]
117
+ assert_equal '52' , last_response . headers [ 'Content-Length ' ]
118
118
end
119
119
120
120
test "not modified partial response with fingerprint and if-none-match etags match" do
121
121
get "/assets/application.js"
122
122
assert_equal 200 , last_response . status
123
123
124
- etag = last_response . headers [ 'etag ' ]
124
+ etag = last_response . headers [ 'ETag ' ]
125
125
digest = etag [ /"(.+)"/ , 1 ]
126
126
127
127
get "/assets/application-#{ digest } .js" , { } ,
@@ -133,7 +133,7 @@ def app
133
133
get "/assets/prehashed-988881adc9fc3655077dc2d4d757d480b5ea0e11.js"
134
134
assert_equal 200 , last_response . status
135
135
136
- etag = last_response . headers [ 'etag ' ]
136
+ etag = last_response . headers [ 'ETag ' ]
137
137
digest = etag [ /"(.+)"/ , 1 ]
138
138
139
139
assert_equal 'edabfd0f1ac5fcdae82cc7d92d1c52abb671797a3948fa9040aec1db8e61c327' , digest
@@ -153,7 +153,7 @@ def app
153
153
get "/assets/application.js"
154
154
assert_equal 200 , last_response . status
155
155
156
- etag = last_response . headers [ 'etag ' ]
156
+ etag = last_response . headers [ 'ETag ' ]
157
157
digest = etag [ /"(.+)"/ , 1 ]
158
158
159
159
get "/assets/application-#{ digest } .js" , { } ,
@@ -177,7 +177,7 @@ def app
177
177
get "/assets/application.js"
178
178
assert_equal 200 , last_response . status
179
179
180
- etag = last_response . headers [ 'etag ' ]
180
+ etag = last_response . headers [ 'ETag ' ]
181
181
182
182
get "/assets/application-0000000000000000000000000000000000000000.js" , { } ,
183
183
'HTTP_IF_NONE_MATCH' => etag
@@ -187,22 +187,22 @@ def app
187
187
test "ok partial response when if-match etags match" do
188
188
get "/assets/application.js"
189
189
assert_equal 200 , last_response . status
190
- etag = last_response . headers [ 'etag ' ]
190
+ etag = last_response . headers [ 'ETag ' ]
191
191
192
192
get "/assets/application.js" , { } ,
193
193
'HTTP_IF_MATCH' => etag
194
194
195
195
assert_equal 200 , last_response . status
196
- assert_equal '"b452c9ae1d5c8d9246653e0d93bc83abce0ee09ef725c0f0a29a41269c217b83"' , last_response . headers [ 'etag ' ]
197
- assert_equal '52' , last_response . headers [ 'content-length ' ]
196
+ assert_equal '"b452c9ae1d5c8d9246653e0d93bc83abce0ee09ef725c0f0a29a41269c217b83"' , last_response . headers [ 'ETag ' ]
197
+ assert_equal '52' , last_response . headers [ 'Content-Length ' ]
198
198
end
199
199
200
200
test "precondition failed with if-match is a mismatch" do
201
201
get "/assets/application.js" , { } ,
202
202
'HTTP_IF_MATCH' => '"000"'
203
203
assert_equal 412 , last_response . status
204
204
205
- refute last_response . headers [ 'etag ' ]
205
+ refute last_response . headers [ 'ETag ' ]
206
206
end
207
207
208
208
test "not found with if-match" do
@@ -225,23 +225,23 @@ def app
225
225
226
226
test "fingerprint digest sets expiration to the future" do
227
227
get "/assets/application.js"
228
- digest = last_response . headers [ 'etag ' ] [ /"(.+)"/ , 1 ]
228
+ digest = last_response . headers [ 'ETag ' ] [ /"(.+)"/ , 1 ]
229
229
230
230
get "/assets/application-#{ digest } .js"
231
231
assert_equal 200 , last_response . status
232
- assert_match %r{max-age} , last_response . headers [ 'cache-control ' ]
233
- assert_match %r{immutable} , last_response . headers [ 'cache-control ' ]
232
+ assert_match %r{max-age} , last_response . headers [ 'Cache-Control ' ]
233
+ assert_match %r{immutable} , last_response . headers [ 'Cache-Control ' ]
234
234
end
235
235
236
236
test "fingerprint digest of file self" do
237
237
get "/assets/application.self.js"
238
- digest = last_response . headers [ 'etag ' ] [ /"(.+)"/ , 1 ]
238
+ digest = last_response . headers [ 'ETag ' ] [ /"(.+)"/ , 1 ]
239
239
240
240
get "/assets/application.self-#{ digest } .js"
241
241
assert_equal 200 , last_response . status
242
242
assert_equal "\n (function() {\n application.boot();\n })();\n " , last_response . body
243
- assert_equal "43" , last_response . headers [ 'content-length ' ]
244
- assert_match %r{max-age} , last_response . headers [ 'cache-control ' ]
243
+ assert_equal "43" , last_response . headers [ 'Content-Length ' ]
244
+ assert_match %r{max-age} , last_response . headers [ 'Cache-Control ' ]
245
245
end
246
246
247
247
test "bad fingerprint digest returns a 404" do
@@ -250,14 +250,14 @@ def app
250
250
251
251
head "/assets/application-0000000000000000000000000000000000000000.js"
252
252
assert_equal 404 , last_response . status
253
- assert_equal "0" , last_response . headers [ 'content-length ' ]
253
+ assert_equal "0" , last_response . headers [ 'Content-Length ' ]
254
254
assert_equal "" , last_response . body
255
255
end
256
256
257
257
test "missing source" do
258
258
get "/assets/none.js"
259
259
assert_equal 404 , last_response . status
260
- assert_equal "pass" , last_response . headers [ 'x-cascade ' ]
260
+ assert_equal "pass" , last_response . headers [ 'X-Cascade ' ]
261
261
end
262
262
263
263
test "re-throw JS exceptions in the browser" do
@@ -302,7 +302,7 @@ def app
302
302
303
303
head "/assets/.-0000000./etc/passwd"
304
304
assert_equal 403 , last_response . status
305
- assert_equal "0" , last_response . headers [ 'content-length ' ]
305
+ assert_equal "0" , last_response . headers [ 'Content-Length ' ]
306
306
assert_equal "" , last_response . body
307
307
end
308
308
@@ -336,7 +336,7 @@ def app
336
336
test "serving static assets" do
337
337
get "/assets/logo.png"
338
338
assert_equal 200 , last_response . status
339
- assert_equal "image/png" , last_response . headers [ 'content-type ' ]
339
+ assert_equal "image/png" , last_response . headers [ 'Content-Type ' ]
340
340
refute last_response . headers [ 'Content-Encoding' ]
341
341
assert_equal File . binread ( fixture_path ( "server/app/images/logo.png" ) ) , last_response . body
342
342
end
@@ -347,8 +347,8 @@ def app
347
347
348
348
head "/assets/foo.js"
349
349
assert_equal 200 , last_response . status
350
- assert_equal "application/javascript" , last_response . headers [ 'content-type ' ]
351
- assert_equal "0" , last_response . headers [ 'content-length ' ]
350
+ assert_equal "application/javascript" , last_response . headers [ 'Content-Type ' ]
351
+ assert_equal "0" , last_response . headers [ 'Content-Length ' ]
352
352
assert_equal "" , last_response . body
353
353
354
354
post "/assets/foo.js"
0 commit comments