lib/rack/iframe.rb in rack-iframe-0.0.1 vs lib/rack/iframe.rb in rack-iframe-0.0.2

- old
+ new

@@ -4,22 +4,28 @@ module Rack class Iframe DEFAULT_P3P = %(CP="ALL DSP COR CURa ADMa DEVa OUR IND COM NAV").freeze + DEFAULT_IFRAME_SESSION_PATH = '/iframe_session'.freeze def initialize(app, options = {}) @app, @options = app, options @options[:p3p] ||= DEFAULT_P3P + @options[:iframe_session_path] ||= DEFAULT_IFRAME_SESSION_PATH end def call(env) # 1) If P3P: Set a random Etag (If-None-Match) to trick backend to not send cached response (304). set_invalid_etag!(env) if set_p3p_header?(env) # 2) Request - @status, @headers, @body = @app.call(env) + if iframe_session_path?(env) + @status, @headers, @body = iframe_session_response + else + @status, @headers, @body = @app.call(env) + end # 3) If P3P: Attach P3P header. set_p3p_header! if set_p3p_header?(env) # 4) Response @@ -63,9 +69,17 @@ def user_agents?(ids, env) [*ids].any? do |id| user_agent?(id, env) end + end + + def iframe_session_path?(env) + env['PATH_INFO'] == @options[:iframe_session_path] + end + + def iframe_session_response + [200, {}, [""]] end end end