httprb / http

HTTP (The Gem! a.k.a. http.rb) - a fast Ruby HTTP client with a chainable API, streaming support, and timeouts
MIT License
3.01k stars 321 forks source link

Header key with underscore being converted to a dash #641

Closed kroe761 closed 3 years ago

kroe761 commented 3 years ago

I am trying to create a POST request that contains the key app_token in the header. My code

HTTP.headers({:app_token => "some-guid-token"})
         .post("https://service.mycompany.net/",
                     json: { key: "value"})

However, when I make my call, I am notified that app_token was not proved. Looking at the req in HTTP::Client.request, I see that the header has been converted to App-Token. This is causing my request to fail. Is there a workaround? We are using version 4.4.1.

tarcieri commented 3 years ago

Dup of: #337, #576

kroe761 commented 3 years ago

I've tried this code, and it still results in 'App-Token' as the key in the header

HTTP.headers({"app_token" => "some-guid-token"})
         .post("https://service.mycompany.net/",
                     json: { key: "value"})
tarcieri commented 3 years ago

There's a monkeypatch here:

https://github.com/httprb/http/issues/337#issuecomment-550412661

Otherwise #576 is a more permanent but unreleased fix.

kroe761 commented 3 years ago

Works perfectly! Thank you!