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

Logger outputs canonicalised request headers, rather than logging what is sent #600

Open unikitty37 opened 4 years ago

unikitty37 commented 4 years ago
logger = Logger.new(STDERR)
http_headers = {
  'TEST_ONE' => 1,
  'TEST.TWO' => 2
}
HTTP.headers(http_headers)
    .use(logging: {logger: logger})
    .use(:auto_inflate).headers('Accept-Encoding' => 'gzip')
    .post('https://example.com')

produces this:

I, [2020-03-12T15:51:28.560383 #1]  INFO -- : > POST https://example.com
D, [2020-03-12T15:51:28.560482 #1] DEBUG -- : Test-One: 1
Test.two: 2
Accept-Encoding: gzip
Connection: close
Host: example.com
User-Agent: http.rb/4.3.0

While #576 means the header should be sent as specified in http_headers, it's difficult to confirm this from the logger output! Could the logger output the unaltered header instead, please?

(It would also be useful if it could output a newline before that first header — it tends to get lost in the noise of the timestamp line 🙂)