rack 2.0.9.3 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack might be problematic. Click here for more details.

Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +681 -0
  3. data/CONTRIBUTING.md +136 -0
  4. data/{COPYING → MIT-LICENSE} +4 -2
  5. data/README.rdoc +152 -162
  6. data/Rakefile +37 -23
  7. data/{SPEC → SPEC.rdoc} +35 -10
  8. data/bin/rackup +1 -0
  9. data/example/lobster.ru +2 -0
  10. data/example/protectedlobster.rb +3 -1
  11. data/example/protectedlobster.ru +2 -0
  12. data/lib/rack/auth/abstract/handler.rb +3 -1
  13. data/lib/rack/auth/abstract/request.rb +1 -1
  14. data/lib/rack/auth/basic.rb +7 -4
  15. data/lib/rack/auth/digest/md5.rb +13 -11
  16. data/lib/rack/auth/digest/nonce.rb +6 -3
  17. data/lib/rack/auth/digest/params.rb +4 -2
  18. data/lib/rack/auth/digest/request.rb +5 -3
  19. data/lib/rack/body_proxy.rb +15 -14
  20. data/lib/rack/builder.rb +116 -23
  21. data/lib/rack/cascade.rb +28 -12
  22. data/lib/rack/chunked.rb +68 -20
  23. data/lib/rack/common_logger.rb +33 -28
  24. data/lib/rack/conditional_get.rb +20 -16
  25. data/lib/rack/config.rb +2 -0
  26. data/lib/rack/content_length.rb +8 -7
  27. data/lib/rack/content_type.rb +5 -4
  28. data/lib/rack/core_ext/regexp.rb +14 -0
  29. data/lib/rack/deflater.rb +59 -34
  30. data/lib/rack/directory.rb +84 -64
  31. data/lib/rack/etag.rb +5 -4
  32. data/lib/rack/events.rb +19 -20
  33. data/lib/rack/file.rb +4 -173
  34. data/lib/rack/files.rb +218 -0
  35. data/lib/rack/handler/cgi.rb +2 -3
  36. data/lib/rack/handler/fastcgi.rb +4 -4
  37. data/lib/rack/handler/lsws.rb +3 -3
  38. data/lib/rack/handler/scgi.rb +9 -8
  39. data/lib/rack/handler/thin.rb +17 -11
  40. data/lib/rack/handler/webrick.rb +15 -6
  41. data/lib/rack/handler.rb +7 -2
  42. data/lib/rack/head.rb +1 -1
  43. data/lib/rack/lint.rb +72 -26
  44. data/lib/rack/lobster.rb +10 -10
  45. data/lib/rack/lock.rb +2 -1
  46. data/lib/rack/logger.rb +2 -0
  47. data/lib/rack/media_type.rb +10 -5
  48. data/lib/rack/method_override.rb +4 -2
  49. data/lib/rack/mime.rb +9 -1
  50. data/lib/rack/mock.rb +97 -20
  51. data/lib/rack/multipart/generator.rb +17 -13
  52. data/lib/rack/multipart/parser.rb +58 -73
  53. data/lib/rack/multipart/uploaded_file.rb +15 -7
  54. data/lib/rack/multipart.rb +7 -4
  55. data/lib/rack/null_logger.rb +2 -0
  56. data/lib/rack/query_parser.rb +53 -28
  57. data/lib/rack/recursive.rb +7 -5
  58. data/lib/rack/reloader.rb +8 -4
  59. data/lib/rack/request.rb +220 -61
  60. data/lib/rack/response.rb +127 -44
  61. data/lib/rack/rewindable_input.rb +4 -3
  62. data/lib/rack/runtime.rb +6 -4
  63. data/lib/rack/sendfile.rb +13 -9
  64. data/lib/rack/server.rb +95 -24
  65. data/lib/rack/session/abstract/id.rb +33 -21
  66. data/lib/rack/session/cookie.rb +12 -12
  67. data/lib/rack/session/memcache.rb +4 -93
  68. data/lib/rack/session/pool.rb +5 -3
  69. data/lib/rack/show_exceptions.rb +17 -13
  70. data/lib/rack/show_status.rb +5 -5
  71. data/lib/rack/static.rb +23 -11
  72. data/lib/rack/tempfile_reaper.rb +1 -1
  73. data/lib/rack/urlmap.rb +12 -6
  74. data/lib/rack/utils.rb +105 -130
  75. data/lib/rack/version.rb +29 -0
  76. data/lib/rack.rb +67 -73
  77. data/rack.gemspec +40 -28
  78. metadata +39 -182
  79. data/HISTORY.md +0 -520
  80. data/test/builder/an_underscore_app.rb +0 -5
  81. data/test/builder/anything.rb +0 -5
  82. data/test/builder/comment.ru +0 -4
  83. data/test/builder/end.ru +0 -5
  84. data/test/builder/line.ru +0 -1
  85. data/test/builder/options.ru +0 -2
  86. data/test/cgi/assets/folder/test.js +0 -1
  87. data/test/cgi/assets/fonts/font.eot +0 -1
  88. data/test/cgi/assets/images/image.png +0 -1
  89. data/test/cgi/assets/index.html +0 -1
  90. data/test/cgi/assets/javascripts/app.js +0 -1
  91. data/test/cgi/assets/stylesheets/app.css +0 -1
  92. data/test/cgi/lighttpd.conf +0 -26
  93. data/test/cgi/rackup_stub.rb +0 -6
  94. data/test/cgi/sample_rackup.ru +0 -5
  95. data/test/cgi/test +0 -9
  96. data/test/cgi/test+directory/test+file +0 -1
  97. data/test/cgi/test.fcgi +0 -9
  98. data/test/cgi/test.gz +0 -0
  99. data/test/cgi/test.ru +0 -5
  100. data/test/gemloader.rb +0 -10
  101. data/test/helper.rb +0 -34
  102. data/test/multipart/bad_robots +0 -259
  103. data/test/multipart/binary +0 -0
  104. data/test/multipart/content_type_and_no_filename +0 -6
  105. data/test/multipart/empty +0 -10
  106. data/test/multipart/fail_16384_nofile +0 -814
  107. data/test/multipart/file1.txt +0 -1
  108. data/test/multipart/filename_and_modification_param +0 -7
  109. data/test/multipart/filename_and_no_name +0 -6
  110. data/test/multipart/filename_with_encoded_words +0 -7
  111. data/test/multipart/filename_with_escaped_quotes +0 -6
  112. data/test/multipart/filename_with_escaped_quotes_and_modification_param +0 -7
  113. data/test/multipart/filename_with_null_byte +0 -7
  114. data/test/multipart/filename_with_percent_escaped_quotes +0 -6
  115. data/test/multipart/filename_with_single_quote +0 -7
  116. data/test/multipart/filename_with_unescaped_percentages +0 -6
  117. data/test/multipart/filename_with_unescaped_percentages2 +0 -6
  118. data/test/multipart/filename_with_unescaped_percentages3 +0 -6
  119. data/test/multipart/filename_with_unescaped_quotes +0 -6
  120. data/test/multipart/ie +0 -6
  121. data/test/multipart/invalid_character +0 -6
  122. data/test/multipart/mixed_files +0 -21
  123. data/test/multipart/nested +0 -10
  124. data/test/multipart/none +0 -9
  125. data/test/multipart/quoted +0 -15
  126. data/test/multipart/rack-logo.png +0 -0
  127. data/test/multipart/semicolon +0 -6
  128. data/test/multipart/text +0 -15
  129. data/test/multipart/three_files_three_fields +0 -31
  130. data/test/multipart/unity3d_wwwform +0 -11
  131. data/test/multipart/webkit +0 -32
  132. data/test/rackup/config.ru +0 -31
  133. data/test/registering_handler/rack/handler/registering_myself.rb +0 -8
  134. data/test/spec_auth_basic.rb +0 -89
  135. data/test/spec_auth_digest.rb +0 -260
  136. data/test/spec_body_proxy.rb +0 -85
  137. data/test/spec_builder.rb +0 -233
  138. data/test/spec_cascade.rb +0 -63
  139. data/test/spec_cgi.rb +0 -84
  140. data/test/spec_chunked.rb +0 -103
  141. data/test/spec_common_logger.rb +0 -107
  142. data/test/spec_conditional_get.rb +0 -103
  143. data/test/spec_config.rb +0 -23
  144. data/test/spec_content_length.rb +0 -86
  145. data/test/spec_content_type.rb +0 -46
  146. data/test/spec_deflater.rb +0 -375
  147. data/test/spec_directory.rb +0 -148
  148. data/test/spec_etag.rb +0 -108
  149. data/test/spec_events.rb +0 -133
  150. data/test/spec_fastcgi.rb +0 -85
  151. data/test/spec_file.rb +0 -264
  152. data/test/spec_handler.rb +0 -57
  153. data/test/spec_head.rb +0 -46
  154. data/test/spec_lint.rb +0 -520
  155. data/test/spec_lobster.rb +0 -59
  156. data/test/spec_lock.rb +0 -204
  157. data/test/spec_logger.rb +0 -24
  158. data/test/spec_media_type.rb +0 -42
  159. data/test/spec_method_override.rb +0 -110
  160. data/test/spec_mime.rb +0 -51
  161. data/test/spec_mock.rb +0 -359
  162. data/test/spec_multipart.rb +0 -721
  163. data/test/spec_null_logger.rb +0 -21
  164. data/test/spec_recursive.rb +0 -75
  165. data/test/spec_request.rb +0 -1423
  166. data/test/spec_response.rb +0 -528
  167. data/test/spec_rewindable_input.rb +0 -128
  168. data/test/spec_runtime.rb +0 -50
  169. data/test/spec_sendfile.rb +0 -125
  170. data/test/spec_server.rb +0 -193
  171. data/test/spec_session_abstract_id.rb +0 -31
  172. data/test/spec_session_abstract_session_hash.rb +0 -45
  173. data/test/spec_session_cookie.rb +0 -442
  174. data/test/spec_session_memcache.rb +0 -357
  175. data/test/spec_session_persisted_secure_secure_session_hash.rb +0 -73
  176. data/test/spec_session_pool.rb +0 -247
  177. data/test/spec_show_exceptions.rb +0 -93
  178. data/test/spec_show_status.rb +0 -104
  179. data/test/spec_static.rb +0 -184
  180. data/test/spec_tempfile_reaper.rb +0 -64
  181. data/test/spec_thin.rb +0 -96
  182. data/test/spec_urlmap.rb +0 -237
  183. data/test/spec_utils.rb +0 -742
  184. data/test/spec_version.rb +0 -11
  185. data/test/spec_webrick.rb +0 -206
  186. data/test/static/another/index.html +0 -1
  187. data/test/static/foo.html +0 -1
  188. data/test/static/index.html +0 -1
  189. data/test/testrequest.rb +0 -78
  190. data/test/unregistered_handler/rack/handler/unregistered.rb +0 -7
  191. data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +0 -7
data/test/spec_mock.rb DELETED
@@ -1,359 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'yaml'
3
- require 'rack/lint'
4
- require 'rack/mock'
5
- require 'stringio'
6
-
7
- app = Rack::Lint.new(lambda { |env|
8
- req = Rack::Request.new(env)
9
-
10
- env["mock.postdata"] = env["rack.input"].read
11
- if req.GET["error"]
12
- env["rack.errors"].puts req.GET["error"]
13
- env["rack.errors"].flush
14
- end
15
-
16
- body = req.head? ? "" : env.to_yaml
17
- Rack::Response.new(body,
18
- req.GET["status"] || 200,
19
- "Content-Type" => "text/yaml").finish
20
- })
21
-
22
- describe Rack::MockRequest do
23
- it "return a MockResponse" do
24
- res = Rack::MockRequest.new(app).get("")
25
- res.must_be_kind_of Rack::MockResponse
26
- end
27
-
28
- it "be able to only return the environment" do
29
- env = Rack::MockRequest.env_for("")
30
- env.must_be_kind_of Hash
31
- env.must_include "rack.version"
32
- end
33
-
34
- it "return an environment with a path" do
35
- env = Rack::MockRequest.env_for("http://www.example.com/parse?location[]=1&location[]=2&age_group[]=2")
36
- env["QUERY_STRING"].must_equal "location[]=1&location[]=2&age_group[]=2"
37
- env["PATH_INFO"].must_equal "/parse"
38
- env.must_be_kind_of Hash
39
- env.must_include "rack.version"
40
- end
41
-
42
- it "provide sensible defaults" do
43
- res = Rack::MockRequest.new(app).request
44
-
45
- env = YAML.load(res.body)
46
- env["REQUEST_METHOD"].must_equal "GET"
47
- env["SERVER_NAME"].must_equal "example.org"
48
- env["SERVER_PORT"].must_equal "80"
49
- env["QUERY_STRING"].must_equal ""
50
- env["PATH_INFO"].must_equal "/"
51
- env["SCRIPT_NAME"].must_equal ""
52
- env["rack.url_scheme"].must_equal "http"
53
- env["mock.postdata"].must_be :empty?
54
- end
55
-
56
- it "allow GET/POST/PUT/DELETE/HEAD" do
57
- res = Rack::MockRequest.new(app).get("", :input => "foo")
58
- env = YAML.load(res.body)
59
- env["REQUEST_METHOD"].must_equal "GET"
60
-
61
- res = Rack::MockRequest.new(app).post("", :input => "foo")
62
- env = YAML.load(res.body)
63
- env["REQUEST_METHOD"].must_equal "POST"
64
-
65
- res = Rack::MockRequest.new(app).put("", :input => "foo")
66
- env = YAML.load(res.body)
67
- env["REQUEST_METHOD"].must_equal "PUT"
68
-
69
- res = Rack::MockRequest.new(app).patch("", :input => "foo")
70
- env = YAML.load(res.body)
71
- env["REQUEST_METHOD"].must_equal "PATCH"
72
-
73
- res = Rack::MockRequest.new(app).delete("", :input => "foo")
74
- env = YAML.load(res.body)
75
- env["REQUEST_METHOD"].must_equal "DELETE"
76
-
77
- Rack::MockRequest.env_for("/", :method => "HEAD")["REQUEST_METHOD"]
78
- .must_equal "HEAD"
79
-
80
- Rack::MockRequest.env_for("/", :method => "OPTIONS")["REQUEST_METHOD"]
81
- .must_equal "OPTIONS"
82
- end
83
-
84
- it "set content length" do
85
- env = Rack::MockRequest.env_for("/", :input => "foo")
86
- env["CONTENT_LENGTH"].must_equal "3"
87
- end
88
-
89
- it "allow posting" do
90
- res = Rack::MockRequest.new(app).get("", :input => "foo")
91
- env = YAML.load(res.body)
92
- env["mock.postdata"].must_equal "foo"
93
-
94
- res = Rack::MockRequest.new(app).post("", :input => StringIO.new("foo"))
95
- env = YAML.load(res.body)
96
- env["mock.postdata"].must_equal "foo"
97
- end
98
-
99
- it "use all parts of an URL" do
100
- res = Rack::MockRequest.new(app).
101
- get("https://bla.example.org:9292/meh/foo?bar")
102
- res.must_be_kind_of Rack::MockResponse
103
-
104
- env = YAML.load(res.body)
105
- env["REQUEST_METHOD"].must_equal "GET"
106
- env["SERVER_NAME"].must_equal "bla.example.org"
107
- env["SERVER_PORT"].must_equal "9292"
108
- env["QUERY_STRING"].must_equal "bar"
109
- env["PATH_INFO"].must_equal "/meh/foo"
110
- env["rack.url_scheme"].must_equal "https"
111
- end
112
-
113
- it "set SSL port and HTTP flag on when using https" do
114
- res = Rack::MockRequest.new(app).
115
- get("https://example.org/foo")
116
- res.must_be_kind_of Rack::MockResponse
117
-
118
- env = YAML.load(res.body)
119
- env["REQUEST_METHOD"].must_equal "GET"
120
- env["SERVER_NAME"].must_equal "example.org"
121
- env["SERVER_PORT"].must_equal "443"
122
- env["QUERY_STRING"].must_equal ""
123
- env["PATH_INFO"].must_equal "/foo"
124
- env["rack.url_scheme"].must_equal "https"
125
- env["HTTPS"].must_equal "on"
126
- end
127
-
128
- it "prepend slash to uri path" do
129
- res = Rack::MockRequest.new(app).
130
- get("foo")
131
- res.must_be_kind_of Rack::MockResponse
132
-
133
- env = YAML.load(res.body)
134
- env["REQUEST_METHOD"].must_equal "GET"
135
- env["SERVER_NAME"].must_equal "example.org"
136
- env["SERVER_PORT"].must_equal "80"
137
- env["QUERY_STRING"].must_equal ""
138
- env["PATH_INFO"].must_equal "/foo"
139
- env["rack.url_scheme"].must_equal "http"
140
- end
141
-
142
- it "properly convert method name to an uppercase string" do
143
- res = Rack::MockRequest.new(app).request(:get)
144
- env = YAML.load(res.body)
145
- env["REQUEST_METHOD"].must_equal "GET"
146
- end
147
-
148
- it "accept params and build query string for GET requests" do
149
- res = Rack::MockRequest.new(app).get("/foo?baz=2", :params => {:foo => {:bar => "1"}})
150
- env = YAML.load(res.body)
151
- env["REQUEST_METHOD"].must_equal "GET"
152
- env["QUERY_STRING"].must_include "baz=2"
153
- env["QUERY_STRING"].must_include "foo[bar]=1"
154
- env["PATH_INFO"].must_equal "/foo"
155
- env["mock.postdata"].must_equal ""
156
- end
157
-
158
- it "accept raw input in params for GET requests" do
159
- res = Rack::MockRequest.new(app).get("/foo?baz=2", :params => "foo[bar]=1")
160
- env = YAML.load(res.body)
161
- env["REQUEST_METHOD"].must_equal "GET"
162
- env["QUERY_STRING"].must_include "baz=2"
163
- env["QUERY_STRING"].must_include "foo[bar]=1"
164
- env["PATH_INFO"].must_equal "/foo"
165
- env["mock.postdata"].must_equal ""
166
- end
167
-
168
- it "accept params and build url encoded params for POST requests" do
169
- res = Rack::MockRequest.new(app).post("/foo", :params => {:foo => {:bar => "1"}})
170
- env = YAML.load(res.body)
171
- env["REQUEST_METHOD"].must_equal "POST"
172
- env["QUERY_STRING"].must_equal ""
173
- env["PATH_INFO"].must_equal "/foo"
174
- env["CONTENT_TYPE"].must_equal "application/x-www-form-urlencoded"
175
- env["mock.postdata"].must_equal "foo[bar]=1"
176
- end
177
-
178
- it "accept raw input in params for POST requests" do
179
- res = Rack::MockRequest.new(app).post("/foo", :params => "foo[bar]=1")
180
- env = YAML.load(res.body)
181
- env["REQUEST_METHOD"].must_equal "POST"
182
- env["QUERY_STRING"].must_equal ""
183
- env["PATH_INFO"].must_equal "/foo"
184
- env["CONTENT_TYPE"].must_equal "application/x-www-form-urlencoded"
185
- env["mock.postdata"].must_equal "foo[bar]=1"
186
- end
187
-
188
- it "accept params and build multipart encoded params for POST requests" do
189
- files = Rack::Multipart::UploadedFile.new(File.join(File.dirname(__FILE__), "multipart", "file1.txt"))
190
- res = Rack::MockRequest.new(app).post("/foo", :params => { "submit-name" => "Larry", "files" => files })
191
- env = YAML.load(res.body)
192
- env["REQUEST_METHOD"].must_equal "POST"
193
- env["QUERY_STRING"].must_equal ""
194
- env["PATH_INFO"].must_equal "/foo"
195
- env["CONTENT_TYPE"].must_equal "multipart/form-data; boundary=AaB03x"
196
- # The gsub accounts for differences in YAMLs affect on the data.
197
- env["mock.postdata"].gsub("\r", "").length.must_equal 206
198
- end
199
-
200
- it "behave valid according to the Rack spec" do
201
- url = "https://bla.example.org:9292/meh/foo?bar"
202
- Rack::MockRequest.new(app).get(url, :lint => true).
203
- must_be_kind_of Rack::MockResponse
204
- end
205
-
206
- it "call close on the original body object" do
207
- called = false
208
- body = Rack::BodyProxy.new(['hi']) { called = true }
209
- capp = proc { |e| [200, {'Content-Type' => 'text/plain'}, body] }
210
- called.must_equal false
211
- Rack::MockRequest.new(capp).get('/', :lint => true)
212
- called.must_equal true
213
- end
214
-
215
- it "defaults encoding to ASCII 8BIT" do
216
- req = Rack::MockRequest.env_for("/foo")
217
-
218
- keys = [
219
- Rack::REQUEST_METHOD,
220
- Rack::SERVER_NAME,
221
- Rack::SERVER_PORT,
222
- Rack::QUERY_STRING,
223
- Rack::PATH_INFO,
224
- Rack::HTTPS,
225
- Rack::RACK_URL_SCHEME
226
- ]
227
- keys.each do |k|
228
- assert_equal Encoding::ASCII_8BIT, req[k].encoding
229
- end
230
- end
231
- end
232
-
233
- describe Rack::MockResponse do
234
- it "provide access to the HTTP status" do
235
- res = Rack::MockRequest.new(app).get("")
236
- res.must_be :successful?
237
- res.must_be :ok?
238
-
239
- res = Rack::MockRequest.new(app).get("/?status=404")
240
- res.wont_be :successful?
241
- res.must_be :client_error?
242
- res.must_be :not_found?
243
-
244
- res = Rack::MockRequest.new(app).get("/?status=501")
245
- res.wont_be :successful?
246
- res.must_be :server_error?
247
-
248
- res = Rack::MockRequest.new(app).get("/?status=307")
249
- res.must_be :redirect?
250
-
251
- res = Rack::MockRequest.new(app).get("/?status=201", :lint => true)
252
- res.must_be :empty?
253
- end
254
-
255
- it "provide access to the HTTP headers" do
256
- res = Rack::MockRequest.new(app).get("")
257
- res.must_include "Content-Type"
258
- res.headers["Content-Type"].must_equal "text/yaml"
259
- res.original_headers["Content-Type"].must_equal "text/yaml"
260
- res["Content-Type"].must_equal "text/yaml"
261
- res.content_type.must_equal "text/yaml"
262
- res.content_length.wont_equal 0
263
- res.location.must_be_nil
264
- end
265
-
266
- it "provide access to the HTTP body" do
267
- res = Rack::MockRequest.new(app).get("")
268
- res.body.must_match(/rack/)
269
- assert_match(res, /rack/)
270
- end
271
-
272
- it "provide access to the Rack errors" do
273
- res = Rack::MockRequest.new(app).get("/?error=foo", :lint => true)
274
- res.must_be :ok?
275
- res.errors.wont_be :empty?
276
- res.errors.must_include "foo"
277
- end
278
-
279
- it "allow calling body.close afterwards" do
280
- # this is exactly what rack-test does
281
- body = StringIO.new("hi")
282
- res = Rack::MockResponse.new(200, {}, body)
283
- body.close if body.respond_to?(:close)
284
- res.body.must_equal 'hi'
285
- end
286
-
287
- it "optionally make Rack errors fatal" do
288
- lambda {
289
- Rack::MockRequest.new(app).get("/?error=foo", :fatal => true)
290
- }.must_raise Rack::MockRequest::FatalWarning
291
- end
292
- end
293
-
294
- describe Rack::MockResponse, 'headers' do
295
- before do
296
- @res = Rack::MockRequest.new(app).get('')
297
- @res.set_header 'FOO', '1'
298
- end
299
-
300
- it 'has_header?' do
301
- lambda { @res.has_header? nil }.must_raise NoMethodError
302
-
303
- @res.has_header?('FOO').must_equal true
304
- @res.has_header?('Foo').must_equal true
305
- end
306
-
307
- it 'get_header' do
308
- lambda { @res.get_header nil }.must_raise NoMethodError
309
-
310
- @res.get_header('FOO').must_equal '1'
311
- @res.get_header('Foo').must_equal '1'
312
- end
313
-
314
- it 'set_header' do
315
- lambda { @res.set_header nil, '1' }.must_raise NoMethodError
316
-
317
- @res.set_header('FOO', '2').must_equal '2'
318
- @res.get_header('FOO').must_equal '2'
319
-
320
- @res.set_header('Foo', '3').must_equal '3'
321
- @res.get_header('Foo').must_equal '3'
322
- @res.get_header('FOO').must_equal '3'
323
-
324
- @res.set_header('FOO', nil).must_be_nil
325
- @res.get_header('FOO').must_be_nil
326
- @res.has_header?('FOO').must_equal true
327
- end
328
-
329
- it 'add_header' do
330
- lambda { @res.add_header nil, '1' }.must_raise NoMethodError
331
-
332
- # Sets header on first addition
333
- @res.add_header('FOO', '1').must_equal '1,1'
334
- @res.get_header('FOO').must_equal '1,1'
335
-
336
- # Ignores nil additions
337
- @res.add_header('FOO', nil).must_equal '1,1'
338
- @res.get_header('FOO').must_equal '1,1'
339
-
340
- # Converts additions to strings
341
- @res.add_header('FOO', 2).must_equal '1,1,2'
342
- @res.get_header('FOO').must_equal '1,1,2'
343
-
344
- # Respects underlying case-sensitivity
345
- @res.add_header('Foo', 'yep').must_equal '1,1,2,yep'
346
- @res.get_header('Foo').must_equal '1,1,2,yep'
347
- @res.get_header('FOO').must_equal '1,1,2,yep'
348
- end
349
-
350
- it 'delete_header' do
351
- lambda { @res.delete_header nil }.must_raise NoMethodError
352
-
353
- @res.delete_header('FOO').must_equal '1'
354
- @res.has_header?('FOO').must_equal false
355
-
356
- @res.has_header?('Foo').must_equal false
357
- @res.delete_header('Foo').must_be_nil
358
- end
359
- end