Class: SockJS::Transports::IFrame
- Defined in:
- lib/sockjs/transports/iframe.rb
Constant Summary collapse
- BODY =
<<-EOB.freeze <!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script> document.domain = document.domain; _sockjs_onload = function(){SockJS.bootstrap_iframe();}; </script> <script src="{{ sockjs_url }}"></script> </head> <body> <h2>Don't panic!</h2> <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p> </body> </html> EOB
Instance Attribute Summary
Attributes inherited from Endpoint
#connection, #http_origin, #options, #remote_addr
Attributes included from Endpoint::ClassMethods
Instance Method Summary collapse
- #body ⇒ Object
- #digest ⇒ Object
- #etag ⇒ Object
-
#handle_request(request) ⇒ Object
Handler.
- #setup_response(request, response) ⇒ Object
Methods inherited from Endpoint
#build_error_response, #build_response, #call, #empty_string, #error_content_type, #format_frame, #handle, #handle_http_error, #initialize, #inspect, #response_class
Methods included from Endpoint::ClassMethods
#add_route, #add_routes, #endpoints, #register, #route_conditions, #routing_prefix
Constructor Details
This class inherits a constructor from SockJS::Endpoint
Instance Method Details
#body ⇒ Object
38 39 40 |
# File 'lib/sockjs/transports/iframe.rb', line 38 def body @body ||= BODY.gsub("{{ sockjs_url }}", [:sockjs_url]) end |
#digest ⇒ Object
42 43 44 |
# File 'lib/sockjs/transports/iframe.rb', line 42 def digest @digest ||= Digest::MD5.new end |
#etag ⇒ Object
46 47 48 |
# File 'lib/sockjs/transports/iframe.rb', line 46 def etag '"' + digest.hexdigest(body) + '"' end |
#handle_request(request) ⇒ Object
Handler.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sockjs/transports/iframe.rb', line 51 def handle_request(request) if request.fresh?(etag) response = build_response(request) response.status = 304 response.finish return response else SockJS.debug "Deferring to Transport" response = build_response(request) response.set_content_type(:html) response.write(body) response.finish return response end end |