Sha256: 2b0a68847d95b8ef3579aeb4d830a774211840b532b1b81db0a51d0961463e6f

Contents?: true

Size: 862 Bytes

Versions: 17

Compression:

Stored size: 862 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

17 entries across 17 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/websocket-driver-0.5.4/lib/websocket/driver/headers.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/websocket-driver-0.5.4/lib/websocket/driver/headers.rb
websocket-driver-0.6.0-java lib/websocket/driver/headers.rb
websocket-driver-0.6.0 lib/websocket/driver/headers.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/websocket-driver-0.5.4/lib/websocket/driver/headers.rb
websocket-driver-0.5.4-java lib/websocket/driver/headers.rb
websocket-driver-0.5.4 lib/websocket/driver/headers.rb
websocket-driver-0.5.3-java lib/websocket/driver/headers.rb
websocket-driver-0.5.3 lib/websocket/driver/headers.rb
websocket-driver-0.5.2-java lib/websocket/driver/headers.rb
websocket-driver-0.5.2 lib/websocket/driver/headers.rb
websocket-driver-0.5.1-java lib/websocket/driver/headers.rb
websocket-driver-0.5.1 lib/websocket/driver/headers.rb
websocket-driver-0.5.0 lib/websocket/driver/headers.rb
websocket-driver-0.5.0-java lib/websocket/driver/headers.rb
websocket-driver-0.4.0-java lib/websocket/driver/headers.rb
websocket-driver-0.4.0 lib/websocket/driver/headers.rb