Reputation: 414
normalize_header in HTTP::headers turns underscores into dashes (https://github.com/httprb/http/issues/337). This isn't correct in some cases. I can easily monkey patch this. But I was trying to figure out how to use a refinement to narrow the scope of the modification.
require "http"
module NormalizeHeaderPatch
refine HTTP::Headers do
def normalize_header(name)
puts "refined normalize_header"
name
end
end
end
using NormalizeHeaderPatch
auth_res = HTTP.headers(
"client_id" => "client_id"
).get("https://www.google.com")
But that doesn't work. My gut is that I have missed something with the refinement not being activated once we are in the scope that ends up calling normalize_header but I don't know how to arrange for that to work.
Upvotes: 1
Views: 102