Sha256: d96a861fb26943bef4d6c46419b20ebadeb30d24e6fe2a4e294691212c23d869

Contents?: true

Size: 864 Bytes

Versions: 23

Compression:

Stored size: 864 Bytes

Contents

module WebSocket
  class Driver

    class Headers
      ALLOWED_DUPLICATES = %w[set-cookie set-cookie2 warning www-authenticate]

      def initialize(received = {})
        @raw = received
        clear

        @received = {}
        @raw.each { |k,v| @received[HTTP.normalize_header(k)] = v }
      end

      def clear
        @sent  = Set.new
        @lines = []
      end

      def [](name)
        @received[HTTP.normalize_header(name)]
      end

      def []=(name, value)
        return if value.nil?
        key = HTTP.normalize_header(name)
        return unless @sent.add?(key) or ALLOWED_DUPLICATES.include?(key)
        @lines << "#{ name.strip }: #{ value.to_s.strip }\r\n"
      end

      def inspect
        @raw.inspect
      end

      def to_h
        @raw.dup
      end

      def to_s
        @lines.join('')
      end
    end

  end
end

Version data entries

23 entries across 23 versions & 8 rubygems

Version Path
websocket-driver-0.7.7-java lib/websocket/driver/headers.rb
websocket-driver-0.7.7 lib/websocket/driver/headers.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/websocket-driver-0.7.6/lib/websocket/driver/headers.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/websocket-driver-0.7.6/lib/websocket/driver/headers.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/websocket-driver-0.7.6/lib/websocket/driver/headers.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/websocket-driver-0.7.6/lib/websocket/driver/headers.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/websocket-driver-0.7.6/lib/websocket/driver/headers.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/websocket-driver-0.7.6/lib/websocket/driver/headers.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/websocket-driver-0.7.5/lib/websocket/driver/headers.rb
websocket-driver-0.7.6-java lib/websocket/driver/headers.rb
websocket-driver-0.7.6 lib/websocket/driver/headers.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/websocket-driver-0.7.5/lib/websocket/driver/headers.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/websocket-driver-0.7.5/lib/websocket/driver/headers.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/websocket-driver-0.7.5/lib/websocket/driver/headers.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/websocket-driver-0.7.5/lib/websocket/driver/headers.rb
websocket-driver-0.7.5-java lib/websocket/driver/headers.rb
websocket-driver-0.7.5 lib/websocket/driver/headers.rb
websocket-driver-0.7.4-java lib/websocket/driver/headers.rb
websocket-driver-0.7.4 lib/websocket/driver/headers.rb
websocket-driver-0.7.3-java lib/websocket/driver/headers.rb