class WebSocket::Driver::Headers - websocket-driver-0.6.5 Documentation

# class WebSocket::Driver::Headers

### Constants

ALLOWED_DUPLICATES

### Public Class Methods

new(received = {}) click to toggle source

    # File lib/websocket/driver/headers.rb, line 7
    def initialize(received = {})
      @raw = received
      clear

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

### Public Instance Methods

[](name) click to toggle source

    # File lib/websocket/driver/headers.rb, line 20
    def [](name)
      @received[HTTP.normalize_header(name)]
    end

[]=(name, value) click to toggle source

    # File lib/websocket/driver/headers.rb, line 24
    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

clear() click to toggle source

    # File lib/websocket/driver/headers.rb, line 15
    def clear
      @sent  = Set.new
      @lines = []
    end

inspect() click to toggle source

    # File lib/websocket/driver/headers.rb, line 31
    def inspect
      @raw.inspect
    end

to_h() click to toggle source

    # File lib/websocket/driver/headers.rb, line 35
    def to_h
      @raw.dup
    end

to_s() click to toggle source

    # File lib/websocket/driver/headers.rb, line 39
    def to_s
      @lines.join('')
    end