Ruby Forum Ruby-core > [Bug #445] [PATCH] Net::HTTPHeaders#fetch raises NoMethodError instead of returning default values

Posted by Arthur Schreiber (Guest)
on 15.08.2008 14:45
(Received via mailing list)
Bug #445: [PATCH] Net::HTTPHeaders#fetch raises NoMethodError instead of 
returning default values
http://redmine.ruby-lang.org/issues/show/445

Author: Arthur Schreiber
Status: Open, Priority: Normal

require "net/http"

class Example
  include Net::HTTPHeader

  attr_accessor :body

  def initialize
    initialize_http_header({})
  end
end

@headers = Example.new

@headers.fetch("My-Header", "bla")
=> NoMethodError: undefined method `join' for "bla":String

@headers.fetch("My-Header") { |key| "#{key}: bla" }
=> NoMethodError: undefined method `join' for "bla":String

NoMethodError: undefined method `join' for "my-header: bla":String

The attached Patch fixes this issue.