rack 1.6.12 → 2.0.3
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.
- checksums.yaml +5 -5
- data/COPYING +1 -1
- data/HISTORY.md +138 -8
- data/README.rdoc +17 -25
- data/Rakefile +6 -14
- data/SPEC +10 -11
- data/contrib/rack_logo.svg +164 -111
- data/example/protectedlobster.rb +1 -1
- data/example/protectedlobster.ru +1 -1
- data/lib/rack.rb +70 -21
- data/lib/rack/auth/abstract/request.rb +5 -1
- data/lib/rack/auth/digest/params.rb +2 -3
- data/lib/rack/auth/digest/request.rb +1 -1
- data/lib/rack/body_proxy.rb +14 -9
- data/lib/rack/builder.rb +3 -3
- data/lib/rack/chunked.rb +5 -5
- data/lib/rack/{commonlogger.rb → common_logger.rb} +3 -3
- data/lib/rack/{conditionalget.rb → conditional_get.rb} +0 -0
- data/lib/rack/content_length.rb +2 -2
- data/lib/rack/deflater.rb +4 -39
- data/lib/rack/directory.rb +66 -54
- data/lib/rack/etag.rb +4 -3
- data/lib/rack/events.rb +154 -0
- data/lib/rack/file.rb +64 -40
- data/lib/rack/handler.rb +3 -25
- data/lib/rack/handler/cgi.rb +15 -16
- data/lib/rack/handler/fastcgi.rb +13 -14
- data/lib/rack/handler/lsws.rb +11 -11
- data/lib/rack/handler/scgi.rb +15 -15
- data/lib/rack/handler/thin.rb +3 -0
- data/lib/rack/handler/webrick.rb +24 -26
- data/lib/rack/head.rb +15 -17
- data/lib/rack/lint.rb +40 -40
- data/lib/rack/lobster.rb +1 -1
- data/lib/rack/lock.rb +6 -10
- data/lib/rack/logger.rb +2 -2
- data/lib/rack/media_type.rb +38 -0
- data/lib/rack/{methodoverride.rb → method_override.rb} +6 -10
- data/lib/rack/mime.rb +18 -5
- data/lib/rack/mock.rb +36 -54
- data/lib/rack/multipart.rb +35 -6
- data/lib/rack/multipart/generator.rb +5 -5
- data/lib/rack/multipart/parser.rb +272 -158
- data/lib/rack/multipart/uploaded_file.rb +1 -2
- data/lib/rack/{nulllogger.rb → null_logger.rb} +1 -1
- data/lib/rack/query_parser.rb +192 -0
- data/lib/rack/recursive.rb +8 -8
- data/lib/rack/request.rb +383 -307
- data/lib/rack/response.rb +130 -57
- data/lib/rack/rewindable_input.rb +1 -12
- data/lib/rack/runtime.rb +10 -18
- data/lib/rack/sendfile.rb +5 -7
- data/lib/rack/server.rb +30 -23
- data/lib/rack/session/abstract/id.rb +108 -138
- data/lib/rack/session/cookie.rb +26 -28
- data/lib/rack/session/memcache.rb +8 -14
- data/lib/rack/session/pool.rb +14 -21
- data/lib/rack/show_exceptions.rb +386 -0
- data/lib/rack/{showstatus.rb → show_status.rb} +3 -3
- data/lib/rack/static.rb +30 -5
- data/lib/rack/tempfile_reaper.rb +2 -2
- data/lib/rack/urlmap.rb +15 -14
- data/lib/rack/utils.rb +136 -211
- data/rack.gemspec +7 -5
- data/test/builder/an_underscore_app.rb +5 -0
- data/test/builder/options.ru +1 -1
- data/test/cgi/test.fcgi +1 -0
- data/test/cgi/test.gz +0 -0
- data/test/helper.rb +34 -0
- data/test/multipart/filename_with_encoded_words +7 -0
- data/test/multipart/filename_with_single_quote +7 -0
- data/test/multipart/quoted +15 -0
- data/test/multipart/rack-logo.png +0 -0
- data/test/multipart/unity3d_wwwform +11 -0
- data/test/registering_handler/rack/handler/registering_myself.rb +1 -1
- data/test/spec_auth_basic.rb +27 -19
- data/test/spec_auth_digest.rb +47 -46
- data/test/spec_body_proxy.rb +27 -27
- data/test/spec_builder.rb +51 -41
- data/test/spec_cascade.rb +24 -22
- data/test/spec_cgi.rb +49 -67
- data/test/spec_chunked.rb +37 -35
- data/test/{spec_commonlogger.rb → spec_common_logger.rb} +23 -21
- data/test/{spec_conditionalget.rb → spec_conditional_get.rb} +29 -28
- data/test/spec_config.rb +3 -2
- data/test/spec_content_length.rb +18 -17
- data/test/spec_content_type.rb +13 -12
- data/test/spec_deflater.rb +85 -49
- data/test/spec_directory.rb +87 -27
- data/test/spec_etag.rb +32 -31
- data/test/spec_events.rb +133 -0
- data/test/spec_fastcgi.rb +50 -72
- data/test/spec_file.rb +120 -77
- data/test/spec_handler.rb +19 -34
- data/test/spec_head.rb +15 -14
- data/test/spec_lint.rb +164 -199
- data/test/spec_lobster.rb +24 -23
- data/test/spec_lock.rb +69 -39
- data/test/spec_logger.rb +4 -3
- data/test/spec_media_type.rb +42 -0
- data/test/{spec_methodoverride.rb → spec_method_override.rb} +22 -37
- data/test/spec_mime.rb +19 -19
- data/test/spec_mock.rb +206 -144
- data/test/spec_multipart.rb +322 -200
- data/test/{spec_nulllogger.rb → spec_null_logger.rb} +5 -4
- data/test/spec_recursive.rb +17 -14
- data/test/spec_request.rb +768 -607
- data/test/spec_response.rb +215 -112
- data/test/spec_rewindable_input.rb +50 -40
- data/test/spec_runtime.rb +11 -10
- data/test/spec_sendfile.rb +30 -35
- data/test/spec_server.rb +78 -52
- data/test/spec_session_abstract_id.rb +11 -33
- data/test/spec_session_abstract_session_hash.rb +45 -0
- data/test/spec_session_cookie.rb +99 -67
- data/test/spec_session_memcache.rb +63 -101
- data/test/spec_session_pool.rb +48 -84
- data/test/spec_show_exceptions.rb +80 -0
- data/test/{spec_showstatus.rb → spec_show_status.rb} +36 -35
- data/test/spec_static.rb +71 -32
- data/test/spec_tempfile_reaper.rb +11 -10
- data/test/spec_thin.rb +55 -50
- data/test/spec_urlmap.rb +79 -78
- data/test/spec_utils.rb +441 -346
- data/test/spec_version.rb +2 -8
- data/test/spec_webrick.rb +93 -68
- data/test/static/foo.html +1 -0
- data/test/testrequest.rb +1 -1
- data/test/unregistered_handler/rack/handler/unregistered.rb +1 -1
- data/test/unregistered_handler/rack/handler/unregistered_long_one.rb +1 -1
- metadata +102 -66
- data/KNOWN-ISSUES +0 -44
- data/lib/rack/backports/uri/common_18.rb +0 -56
- data/lib/rack/backports/uri/common_192.rb +0 -52
- data/lib/rack/backports/uri/common_193.rb +0 -29
- data/lib/rack/handler/evented_mongrel.rb +0 -8
- data/lib/rack/handler/mongrel.rb +0 -106
- data/lib/rack/handler/swiftiplied_mongrel.rb +0 -8
- data/lib/rack/showexceptions.rb +0 -387
- data/lib/rack/utils/okjson.rb +0 -600
- data/test/spec_mongrel.rb +0 -182
- data/test/spec_showexceptions.rb +0 -98
@@ -1,81 +1,50 @@
|
|
1
1
|
# AUTHOR: blink <blinketje@gmail.com>; blink#ruby-lang@irc.freenode.net
|
2
2
|
# bugrep: Andreas Zehnder
|
3
3
|
|
4
|
+
require 'rack'
|
4
5
|
require 'time'
|
5
6
|
require 'rack/request'
|
6
7
|
require 'rack/response'
|
7
|
-
|
8
|
-
require 'securerandom'
|
9
|
-
rescue LoadError
|
10
|
-
# We just won't get securerandom
|
11
|
-
end
|
12
|
-
require "digest/sha2"
|
8
|
+
require 'securerandom'
|
13
9
|
|
14
10
|
module Rack
|
15
11
|
|
16
12
|
module Session
|
17
13
|
|
18
|
-
class SessionId
|
19
|
-
ID_VERSION = 2
|
20
|
-
|
21
|
-
attr_reader :public_id
|
22
|
-
|
23
|
-
def initialize(public_id)
|
24
|
-
@public_id = public_id
|
25
|
-
end
|
26
|
-
|
27
|
-
def private_id
|
28
|
-
"#{ID_VERSION}::#{hash_sid(public_id)}"
|
29
|
-
end
|
30
|
-
|
31
|
-
alias :cookie_value :public_id
|
32
|
-
|
33
|
-
def empty?; false; end
|
34
|
-
def to_s; raise; end
|
35
|
-
def inspect; public_id.inspect; end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def hash_sid(sid)
|
40
|
-
Digest::SHA256.hexdigest(sid)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
14
|
module Abstract
|
45
|
-
ENV_SESSION_KEY = 'rack.session'.freeze
|
46
|
-
ENV_SESSION_OPTIONS_KEY = 'rack.session.options'.freeze
|
47
|
-
|
48
15
|
# SessionHash is responsible to lazily load the session from store.
|
49
16
|
|
50
17
|
class SessionHash
|
51
18
|
include Enumerable
|
52
19
|
attr_writer :id
|
53
20
|
|
54
|
-
|
55
|
-
|
21
|
+
Unspecified = Object.new
|
22
|
+
|
23
|
+
def self.find(req)
|
24
|
+
req.get_header RACK_SESSION
|
56
25
|
end
|
57
26
|
|
58
|
-
def self.set(
|
59
|
-
|
27
|
+
def self.set(req, session)
|
28
|
+
req.set_header RACK_SESSION, session
|
60
29
|
end
|
61
30
|
|
62
|
-
def self.set_options(
|
63
|
-
|
31
|
+
def self.set_options(req, options)
|
32
|
+
req.set_header RACK_SESSION_OPTIONS, options.dup
|
64
33
|
end
|
65
34
|
|
66
|
-
def initialize(store,
|
35
|
+
def initialize(store, req)
|
67
36
|
@store = store
|
68
|
-
@
|
37
|
+
@req = req
|
69
38
|
@loaded = false
|
70
39
|
end
|
71
40
|
|
72
41
|
def id
|
73
42
|
return @id if @loaded or instance_variable_defined?(:@id)
|
74
|
-
@id = @store.send(:extract_session_id, @
|
43
|
+
@id = @store.send(:extract_session_id, @req)
|
75
44
|
end
|
76
45
|
|
77
46
|
def options
|
78
|
-
@
|
47
|
+
@req.session_options
|
79
48
|
end
|
80
49
|
|
81
50
|
def each(&block)
|
@@ -87,7 +56,15 @@ module Rack
|
|
87
56
|
load_for_read!
|
88
57
|
@data[key.to_s]
|
89
58
|
end
|
90
|
-
|
59
|
+
|
60
|
+
def fetch(key, default=Unspecified, &block)
|
61
|
+
load_for_read!
|
62
|
+
if default == Unspecified
|
63
|
+
@data.fetch(key.to_s, &block)
|
64
|
+
else
|
65
|
+
@data.fetch(key.to_s, default, &block)
|
66
|
+
end
|
67
|
+
end
|
91
68
|
|
92
69
|
def has_key?(key)
|
93
70
|
load_for_read!
|
@@ -109,7 +86,7 @@ module Rack
|
|
109
86
|
|
110
87
|
def destroy
|
111
88
|
clear
|
112
|
-
@id = @store.send(:
|
89
|
+
@id = @store.send(:delete_session, @req, id, options)
|
113
90
|
end
|
114
91
|
|
115
92
|
def to_hash
|
@@ -144,7 +121,7 @@ module Rack
|
|
144
121
|
def exists?
|
145
122
|
return @exists if instance_variable_defined?(:@exists)
|
146
123
|
@data = {}
|
147
|
-
@exists = @store.send(:session_exists?, @
|
124
|
+
@exists = @store.send(:session_exists?, @req)
|
148
125
|
end
|
149
126
|
|
150
127
|
def loaded?
|
@@ -157,10 +134,12 @@ module Rack
|
|
157
134
|
end
|
158
135
|
|
159
136
|
def keys
|
137
|
+
load_for_read!
|
160
138
|
@data.keys
|
161
139
|
end
|
162
140
|
|
163
141
|
def values
|
142
|
+
load_for_read!
|
164
143
|
@data.values
|
165
144
|
end
|
166
145
|
|
@@ -175,7 +154,7 @@ module Rack
|
|
175
154
|
end
|
176
155
|
|
177
156
|
def load!
|
178
|
-
@id, session = @store.send(:load_session, @
|
157
|
+
@id, session = @store.send(:load_session, @req)
|
179
158
|
@data = stringify_keys(session)
|
180
159
|
@loaded = true
|
181
160
|
end
|
@@ -191,14 +170,14 @@ module Rack
|
|
191
170
|
|
192
171
|
# ID sets up a basic framework for implementing an id based sessioning
|
193
172
|
# service. Cookies sent to the client for maintaining sessions will only
|
194
|
-
# contain an id reference. Only #
|
173
|
+
# contain an id reference. Only #find_session and #write_session are
|
195
174
|
# required to be overwritten.
|
196
175
|
#
|
197
176
|
# All parameters are optional.
|
198
177
|
# * :key determines the name of the cookie, by default it is
|
199
178
|
# 'rack.session'
|
200
179
|
# * :path, :domain, :expire_after, :secure, and :httponly set the related
|
201
|
-
# cookie options as by Rack::Response#
|
180
|
+
# cookie options as by Rack::Response#set_cookie
|
202
181
|
# * :skip will not a set a cookie in the response nor update the session state
|
203
182
|
# * :defer will not set a cookie in the response but still update the session
|
204
183
|
# state if it is used with a backend
|
@@ -209,9 +188,9 @@ module Rack
|
|
209
188
|
# id will be.
|
210
189
|
#
|
211
190
|
# These options can be set on a per request basis, at the location of
|
212
|
-
# env['rack.session.options']
|
213
|
-
# found within the options hash at the key :id. It is
|
214
|
-
# recommended to change its value.
|
191
|
+
# <tt>env['rack.session.options']</tt>. Additionally the id of the
|
192
|
+
# session can be found within the options hash at the key :id. It is
|
193
|
+
# highly not recommended to change its value.
|
215
194
|
#
|
216
195
|
# Is Rack::Utils::Context compatible.
|
217
196
|
#
|
@@ -220,7 +199,7 @@ module Rack
|
|
220
199
|
|
221
200
|
class Persisted
|
222
201
|
DEFAULT_OPTIONS = {
|
223
|
-
:key =>
|
202
|
+
:key => RACK_SESSION,
|
224
203
|
:path => '/',
|
225
204
|
:domain => nil,
|
226
205
|
:expire_after => nil,
|
@@ -230,10 +209,10 @@ module Rack
|
|
230
209
|
:renew => false,
|
231
210
|
:sidbits => 128,
|
232
211
|
:cookie_only => true,
|
233
|
-
:secure_random =>
|
234
|
-
}
|
212
|
+
:secure_random => ::SecureRandom
|
213
|
+
}.freeze
|
235
214
|
|
236
|
-
attr_reader :key, :default_options
|
215
|
+
attr_reader :key, :default_options, :sid_secure
|
237
216
|
|
238
217
|
def initialize(app, options={})
|
239
218
|
@app = app
|
@@ -248,13 +227,20 @@ module Rack
|
|
248
227
|
end
|
249
228
|
|
250
229
|
def context(env, app=@app)
|
251
|
-
|
252
|
-
|
253
|
-
|
230
|
+
req = make_request env
|
231
|
+
prepare_session(req)
|
232
|
+
status, headers, body = app.call(req.env)
|
233
|
+
res = Rack::Response::Raw.new status, headers
|
234
|
+
commit_session(req, res)
|
235
|
+
[status, headers, body]
|
254
236
|
end
|
255
237
|
|
256
238
|
private
|
257
239
|
|
240
|
+
def make_request(env)
|
241
|
+
Rack::Request.new env
|
242
|
+
end
|
243
|
+
|
258
244
|
def initialize_sid
|
259
245
|
@sidbits = @default_options[:sidbits]
|
260
246
|
@sid_secure = @default_options[:secure_random]
|
@@ -278,26 +264,26 @@ module Rack
|
|
278
264
|
# Sets the lazy session at 'rack.session' and places options and session
|
279
265
|
# metadata into 'rack.session.options'.
|
280
266
|
|
281
|
-
def prepare_session(
|
282
|
-
session_was
|
283
|
-
|
284
|
-
|
285
|
-
|
267
|
+
def prepare_session(req)
|
268
|
+
session_was = req.get_header RACK_SESSION
|
269
|
+
session = session_class.new(self, req)
|
270
|
+
req.set_header RACK_SESSION, session
|
271
|
+
req.set_header RACK_SESSION_OPTIONS, @default_options.dup
|
272
|
+
session.merge! session_was if session_was
|
286
273
|
end
|
287
274
|
|
288
275
|
# Extracts the session id from provided cookies and passes it and the
|
289
|
-
# environment to #
|
276
|
+
# environment to #find_session.
|
290
277
|
|
291
|
-
def load_session(
|
292
|
-
sid = current_session_id(
|
293
|
-
sid, session =
|
278
|
+
def load_session(req)
|
279
|
+
sid = current_session_id(req)
|
280
|
+
sid, session = find_session(req, sid)
|
294
281
|
[sid, session || {}]
|
295
282
|
end
|
296
283
|
|
297
284
|
# Extract session id from request object.
|
298
285
|
|
299
|
-
def extract_session_id(
|
300
|
-
request = Rack::Request.new(env)
|
286
|
+
def extract_session_id(request)
|
301
287
|
sid = request.cookies[@key]
|
302
288
|
sid ||= request.params[@key] unless @cookie_only
|
303
289
|
sid
|
@@ -305,26 +291,26 @@ module Rack
|
|
305
291
|
|
306
292
|
# Returns the current session id from the SessionHash.
|
307
293
|
|
308
|
-
def current_session_id(
|
309
|
-
|
294
|
+
def current_session_id(req)
|
295
|
+
req.get_header(RACK_SESSION).id
|
310
296
|
end
|
311
297
|
|
312
298
|
# Check if the session exists or not.
|
313
299
|
|
314
|
-
def session_exists?(
|
315
|
-
value = current_session_id(
|
300
|
+
def session_exists?(req)
|
301
|
+
value = current_session_id(req)
|
316
302
|
value && !value.empty?
|
317
303
|
end
|
318
304
|
|
319
305
|
# Session should be committed if it was loaded, any of specific options like :renew, :drop
|
320
306
|
# or :expire_after was given and the security permissions match. Skips if skip is given.
|
321
307
|
|
322
|
-
def commit_session?(
|
308
|
+
def commit_session?(req, session, options)
|
323
309
|
if options[:skip]
|
324
310
|
false
|
325
311
|
else
|
326
312
|
has_session = loaded_session?(session) || forced_session_update?(session, options)
|
327
|
-
has_session && security_matches?(
|
313
|
+
has_session && security_matches?(req, options)
|
328
314
|
end
|
329
315
|
end
|
330
316
|
|
@@ -340,58 +326,52 @@ module Rack
|
|
340
326
|
options.values_at(:max_age, :renew, :drop, :defer, :expire_after).any?
|
341
327
|
end
|
342
328
|
|
343
|
-
def security_matches?(
|
329
|
+
def security_matches?(request, options)
|
344
330
|
return true unless options[:secure]
|
345
|
-
request = Rack::Request.new(env)
|
346
331
|
request.ssl?
|
347
332
|
end
|
348
333
|
|
349
334
|
# Acquires the session from the environment and the session id from
|
350
|
-
# the session options and passes them to #
|
335
|
+
# the session options and passes them to #write_session. If successful
|
351
336
|
# and the :defer option is not true, a cookie will be added to the
|
352
337
|
# response with the session's id.
|
353
338
|
|
354
|
-
def commit_session(
|
355
|
-
session =
|
339
|
+
def commit_session(req, res)
|
340
|
+
session = req.get_header RACK_SESSION
|
356
341
|
options = session.options
|
357
342
|
|
358
343
|
if options[:drop] || options[:renew]
|
359
|
-
session_id =
|
360
|
-
return
|
344
|
+
session_id = delete_session(req, session.id || generate_sid, options)
|
345
|
+
return unless session_id
|
361
346
|
end
|
362
347
|
|
363
|
-
return
|
348
|
+
return unless commit_session?(req, session, options)
|
364
349
|
|
365
350
|
session.send(:load!) unless loaded_session?(session)
|
366
351
|
session_id ||= session.id
|
367
352
|
session_data = session.to_hash.delete_if { |k,v| v.nil? }
|
368
353
|
|
369
|
-
if not data =
|
370
|
-
|
354
|
+
if not data = write_session(req, session_id, session_data, options)
|
355
|
+
req.get_header(RACK_ERRORS).puts("Warning! #{self.class.name} failed to save session. Content dropped.")
|
371
356
|
elsif options[:defer] and not options[:renew]
|
372
|
-
|
357
|
+
req.get_header(RACK_ERRORS).puts("Deferring cookie for #{session_id}") if $VERBOSE
|
373
358
|
else
|
374
359
|
cookie = Hash.new
|
375
|
-
cookie[:value] =
|
360
|
+
cookie[:value] = data
|
376
361
|
cookie[:expires] = Time.now + options[:expire_after] if options[:expire_after]
|
377
362
|
cookie[:expires] = Time.now + options[:max_age] if options[:max_age]
|
378
|
-
set_cookie(
|
363
|
+
set_cookie(req, res, cookie.merge!(options))
|
379
364
|
end
|
380
|
-
|
381
|
-
[status, headers, body]
|
382
|
-
end
|
383
|
-
|
384
|
-
def cookie_value(data)
|
385
|
-
data
|
386
365
|
end
|
366
|
+
public :commit_session
|
387
367
|
|
388
368
|
# Sets the cookie back to the client with session id. We skip the cookie
|
389
369
|
# setting if the value didn't change (sid is the same) or expires was given.
|
390
370
|
|
391
|
-
def set_cookie(
|
392
|
-
request = Rack::Request.new(env)
|
371
|
+
def set_cookie(request, res, cookie)
|
393
372
|
if request.cookies[@key] != cookie[:value] || cookie[:expires]
|
394
|
-
|
373
|
+
res.set_cookie_header =
|
374
|
+
Utils.add_cookie_to_header(res.set_cookie_header, @key, cookie)
|
395
375
|
end
|
396
376
|
end
|
397
377
|
|
@@ -406,68 +386,58 @@ module Rack
|
|
406
386
|
# If nil is provided as the session id, generation of a new valid id
|
407
387
|
# should occur within.
|
408
388
|
|
409
|
-
def
|
410
|
-
raise '#
|
389
|
+
def find_session(env, sid)
|
390
|
+
raise '#find_session not implemented.'
|
411
391
|
end
|
412
392
|
|
413
393
|
# All thread safety and session storage procedures should occur here.
|
414
394
|
# Must return the session id if the session was saved successfully, or
|
415
395
|
# false if the session could not be saved.
|
416
396
|
|
417
|
-
def
|
418
|
-
raise '#
|
397
|
+
def write_session(req, sid, session, options)
|
398
|
+
raise '#write_session not implemented.'
|
419
399
|
end
|
420
400
|
|
421
401
|
# All thread safety and session destroy procedures should occur here.
|
422
402
|
# Should return a new session id or nil if options[:drop]
|
423
403
|
|
424
|
-
def
|
425
|
-
raise '#
|
404
|
+
def delete_session(req, sid, options)
|
405
|
+
raise '#delete_session not implemented'
|
426
406
|
end
|
427
407
|
end
|
428
408
|
|
429
|
-
class
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
else
|
436
|
-
super
|
437
|
-
end
|
409
|
+
class ID < Persisted
|
410
|
+
def self.inherited(klass)
|
411
|
+
k = klass.ancestors.find { |kl| kl.respond_to?(:superclass) && kl.superclass == ID }
|
412
|
+
unless k.instance_variable_defined?(:"@_rack_warned")
|
413
|
+
warn "#{klass} is inheriting from #{ID}. Inheriting from #{ID} is deprecated, please inherit from #{Persisted} instead" if $VERBOSE
|
414
|
+
k.instance_variable_set(:"@_rack_warned", true)
|
438
415
|
end
|
416
|
+
super
|
439
417
|
end
|
440
418
|
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
end
|
419
|
+
# All thread safety and session retrieval procedures should occur here.
|
420
|
+
# Should return [session_id, session].
|
421
|
+
# If nil is provided as the session id, generation of a new valid id
|
422
|
+
# should occur within.
|
446
423
|
|
447
|
-
def
|
448
|
-
|
449
|
-
public_id && SessionId.new(public_id)
|
424
|
+
def find_session(req, sid)
|
425
|
+
get_session req.env, sid
|
450
426
|
end
|
451
427
|
|
452
|
-
|
428
|
+
# All thread safety and session storage procedures should occur here.
|
429
|
+
# Must return the session id if the session was saved successfully, or
|
430
|
+
# false if the session could not be saved.
|
453
431
|
|
454
|
-
def
|
455
|
-
|
432
|
+
def write_session(req, sid, session, options)
|
433
|
+
set_session req.env, sid, session, options
|
456
434
|
end
|
457
435
|
|
458
|
-
|
459
|
-
|
460
|
-
end
|
461
|
-
end
|
436
|
+
# All thread safety and session destroy procedures should occur here.
|
437
|
+
# Should return a new session id or nil if options[:drop]
|
462
438
|
|
463
|
-
|
464
|
-
|
465
|
-
k = klass.ancestors.find { |kl| kl.respond_to?(:superclass) && kl.superclass == ID }
|
466
|
-
unless k.instance_variable_defined?(:"@_rack_warned")
|
467
|
-
warn "#{klass} is inheriting from #{ID}. Inheriting from #{ID} is deprecated, please inherit from #{Persisted} instead" if $VERBOSE
|
468
|
-
k.instance_variable_set(:"@_rack_warned", true)
|
469
|
-
end
|
470
|
-
super
|
439
|
+
def delete_session(req, sid, options)
|
440
|
+
destroy_session req.env, sid, options
|
471
441
|
end
|
472
442
|
end
|
473
443
|
end
|