I am able to access api when try wit curl cmd, but same not able to access with net/http,
I did the string patch as per this link Preserving case in HTTP headers with Ruby's Net:HTTP and it was working well with ruby 2.2.4,
but recently we migrated to ruby 2.6.5 version, since then we are facing this issue again.
can anyone could help me with it.
sample code
token = JSON.parse(token_id)
request = Net::HTTP::Get.new(uri)
sso_token = token["headers"][0]["value"][0]
request[CaseSensitiveString.new('sso_token')] = sso_token
request["Accept"] = "application/json"
req_options = {
use_ssl: uri.scheme == "https"
}
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
response.code
response.body
class CaseSensitiveString < String
def downcase
self
end
def capitalize
self
end
end
Sorry, I needed to patch net/http as we have large existing project and its working with below code for ruby 2.5 and above
module Net::HTTPHeader
def capitalize(name)
name
end
private :capitalize
end