class Thin::Headers
Store HTTP header name-value pairs direcly to a string and allow duplicated entries on some names.
Constants
- ALLOWED_DUPLICATES
- HEADER_FORMAT
Public Class Methods
new()
click to toggle source
# File lib/thin/headers.rb, line 8 def initialize @sent = {} @out = [] end
Public Instance Methods
[]=(key, value)
click to toggle source
Add key: value
pair to the headers. Ignore if already sent and no duplicates are allowed for this key
.
# File lib/thin/headers.rb, line 16 def []=(key, value) if !@sent.has_key?(key) || ALLOWED_DUPLICATES.include?(key) @sent[key] = true value = case value when Time value.httpdate when NilClass return else value.to_s end @out << HEADER_FORMAT % [key, value] end end
has_key?(key)
click to toggle source
# File lib/thin/headers.rb, line 31 def has_key?(key) @sent[key] end
to_s()
click to toggle source
# File lib/thin/headers.rb, line 35 def to_s @out.join end