Based on the Tin Man's answer that the Net::HTTP
library is calling #downcase
on your custom header key (and all header keys), here are some additional options that don't monkey-patch the whole of Net::HTTP
.
You could try this:
custom_header_key = "X-miXEd-cASe"
def custom_header_key.downcase
self
end
To avoid clearing the method cache, either store the result of the above in a class-level constant:
custom_header_key = "X-miXEd-cASe"
def custom_header_key.downcase
self
end
CUSTOM_HEADER_KEY = custom_header_key
or subclass String to override that particular behavior:
class StringWithIdentityDowncase < String
def downcase
self
end
end
custom_header_key = StringWithIdentityDowncase.new("X-miXEd-cASe")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…