Sha256: 826573886fbec403704adfacf05fc00cbae57b8bcf90ea6d751ac85836c17288

Contents?: true

Size: 550 Bytes

Versions: 4

Compression:

Stored size: 550 Bytes

Contents

module Thin
  # Store HTTP header name-value pairs direcly to a string
  # and allow duplicated entries on some names.
  class Headers
    HEADER_FORMAT      = "%s: %s\r\n".freeze
    ALLOWED_DUPLICATES = %w(Set-Cookie Set-Cookie2 Warning WWW-Authenticate).freeze
    
    def initialize
      @sent = {}
      @out = ''
    end
    
    def []=(key, value)
      if !@sent[key] || ALLOWED_DUPLICATES.include?(key)
        @sent[key] = true
        @out << HEADER_FORMAT % [key, value]
      end
    end
    
    def to_s
      @out
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
thin-0.6.0-x86-mswin32-60 lib/thin/headers.rb
thin-0.6.1 lib/thin/headers.rb
thin-0.6.0 lib/thin/headers.rb
thin-0.6.1-x86-mswin32-60 lib/thin/headers.rb