Sha256: 5b63229526d7e4d1d258a2217a14cab41cf4ea387045cf7ba43b354d34481c8a

Contents?: true

Size: 889 Bytes

Versions: 9

Compression:

Stored size: 889 Bytes

Contents

module Firehose
  module Patches
    # Helpers for making Firehose work with Macromedia Flash Sockets. Since this doesn't use "normal" HTTP, we
    # have to monkey patch both Rainbows and Thin to recognize when a request is for a SWF policy.
    module SwfPolicyRequest
      # Borrowed from: https://github.com/igrigorik/em-websocket/blob/3e7f7d7760cc23b9d1d34fc1c17bab4423b5d11a/lib/em-websocket/connection.rb#L104
      def handle_swf_policy_request(data)
        if data =~ /\A<policy-file-request\s*\/>/
          Firehose.logger.debug "Received SWF Policy request: #{data.inspect}"
          send_data policy
          close_connection_after_writing
          true
        end
      end

      def policy
        <<-EOS
  <?xml version="1.0"?>
  <cross-domain-policy>
    <allow-access-from domain="*" to-ports="*"/>
  </cross-domain-policy>
        EOS
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
firehose-1.2.8 lib/firehose/patches/swf_policy_request.rb
firehose-1.2.7 lib/firehose/patches/swf_policy_request.rb
firehose-1.2.6 lib/firehose/patches/swf_policy_request.rb
firehose-1.2.5 lib/firehose/patches/swf_policy_request.rb
firehose-1.2.4 lib/firehose/patches/swf_policy_request.rb
firehose-1.2.3 lib/firehose/patches/swf_policy_request.rb
firehose-1.2.2 lib/firehose/patches/swf_policy_request.rb
firehose-1.2.1 lib/firehose/patches/swf_policy_request.rb
firehose-1.2.0 lib/firehose/patches/swf_policy_request.rb