Class: Rack::Cookieless
- Inherits:
-
Object
- Object
- Rack::Cookieless
- Defined in:
- lib/cookieless.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Cookieless
constructor
A new instance of Cookieless.
Constructor Details
#initialize(app, options = {}) ⇒ Cookieless
Returns a new instance of Cookieless.
6 7 8 |
# File 'lib/cookieless.rb', line 6 def initialize(app, ={}) @app, @options = app, end |
Instance Method Details
#call(env) ⇒ Object
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 |
# File 'lib/cookieless.rb', line 10 def call(env) # have cookies or not = env["HTTP_COOKIE"].present? noconvert = @options[:noconvert].is_a?(Proc) ? @options[:noconvert].call(env) : false if || noconvert @app.call(env) else session_id, = (env["QUERY_STRING"], env) || ((URI.parse(env['HTTP_REFERER']).query rescue nil), env) env["HTTP_COOKIE"] = if status, header, response = @app.call(env) if env['action_dispatch.request.path_parameters'] && %w(css js xml).exclude?(env['action_dispatch.request.path_parameters'][:format].to_s) session_id = (session_id || env["rack.session"]["session_id"], env, header["Set-Cookie"]) ## fix 3xx redirect header["Location"] = convert_url(header["Location"], session_id) if header["Location"] ## only process html page if response.respond_to?(:body) response.body = process_body(response.body, session_id) elsif response.is_a?(Array) and [ActionView::OutputBuffer,String].detect{ |klass| response[0].is_a?(klass)} response[0] = process_body(response[0].to_s, session_id) end end [status, header, response] end end |