class Hoss::Transport::Headers

@api private

Constants

GZIP_HEADERS
HEADERS

Attributes

hash[RW]

Public Class Methods

new(config, initial: {}) click to toggle source
# File lib/hoss/transport/headers.rb, line 32
def initialize(config, initial: {})
  @config = config
  @hash = build!(initial)
end

Public Instance Methods

[](key) click to toggle source
# File lib/hoss/transport/headers.rb, line 39
def [](key)
  @hash[key]
end
[]=(key, value) click to toggle source
# File lib/hoss/transport/headers.rb, line 43
def []=(key, value)
  @hash[key] = value
end
chunked() click to toggle source
# File lib/hoss/transport/headers.rb, line 60
def chunked
  merge(
    @config.http_compression? ? GZIP_HEADERS : HEADERS
  )
end
merge(other) click to toggle source
# File lib/hoss/transport/headers.rb, line 47
def merge(other)
  self.class.new(@config, initial: @hash.merge(other))
end
merge!(other) click to toggle source
# File lib/hoss/transport/headers.rb, line 51
def merge!(other)
  @hash.merge!(other)
  self
end
to_h() click to toggle source
# File lib/hoss/transport/headers.rb, line 56
def to_h
  @hash
end

Private Instance Methods

build!(headers) click to toggle source
# File lib/hoss/transport/headers.rb, line 68
def build!(headers)
  headers[:'User-Agent'] = UserAgent.new(@config).to_s
  headers
end