Sha256: 3912efc43383bcd0bf3e4f9034cc0014a6e5a8ac1a97a6df17c06c4ac362d6b7

Contents?: true

Size: 622 Bytes

Versions: 3

Compression:

Stored size: 622 Bytes

Contents

class CustomPost < Net::HTTP::Post
    def initialize_http_header(headers)
      @header = {}
      headers.each { |k, v| @header[k.to_s] = [v] }
    end

    def [](name)
      _k, val = header_insensitive_match name
      val
    end

    def []=(name, val)
      key, _val = header_insensitive_match name
      key = name if key.nil?
      if val
        @header[key] = [val]
      else
        @header.delete(key)
      end
    end

    def capitalize(name)
      name
    end

    def header_insensitive_match(name)
      @header.find { |key, _value| key.match Regexp.new(name.to_s, Regexp::IGNORECASE) }
    end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
firetail-1.0.1 lib/case_sensitive_headers.rb
firetail-0.0.1.pre.alpha lib/case_sensitive_headers.rb
firetail-rails-0.0.0 lib/case_sensitive_headers.rb