timber 2.0.21 → 2.0.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f65e44d5582af9d177dabd02f2229adda5ea094b
4
- data.tar.gz: a113bb27776a6403b3b237b49d33c7fbac962758
3
+ metadata.gz: fb727abf7308983fedd10e2b44e661ce337a5fed
4
+ data.tar.gz: 4dd342bfd405154dc7e2cc670789745c8879f01b
5
5
  SHA512:
6
- metadata.gz: 10b371f99e2c4f4203526917a770140095581e17a12b72fba44dfc8db8b2151a198b5e771527fb715f6c9c4fe9e0d1c56772ff6663fb31c07f76bd95210339d4
7
- data.tar.gz: e0b9fd2b91d7de66b4bee5305337afeb5017ec42fff2c76e8374c957af5d88445701aa029fca846f2f7e7778e4ffa7231989ea6c05d3814f307e244e5b2607d0
6
+ metadata.gz: 1e781929108c46a6a4a6979ed4255bb57e2bb8ee86397f95b8da4a517e795778dd715347d993ab627eefe951a565d9890b91d2729c73717c8a8224ce125f2c2c
7
+ data.tar.gz: ac45f8c6b93f67b1829b0771e74b37968ea22e2f413e9bf4ac7952e0c2b292536ebd18f82b807a9721708ba5f20b15be50e85ca7710fa0d96d76287f87d4a7cf
@@ -6,19 +6,26 @@ end
6
6
  if defined?(::Rack::Request)
7
7
  module Timber
8
8
  module Util
9
+ # @private
9
10
  class Request < ::Rack::Request
11
+ HTTP_PREFIX = 'HTTP_'.freeze
12
+
10
13
  def body_content
11
14
  content = body.read
12
15
  body.rewind
13
16
  content
14
17
  end
15
18
 
19
+ # Returns a list of request headers. The rack env contains a lot of data, this function
20
+ # identifies those that were the actual request headers.
16
21
  def headers
17
- @headers ||= ::Hash[*@env.select {|k,v| k.start_with? 'HTTP_'}
18
- .collect {|k,v| [k.sub(/^HTTP_/, ''), v]}
19
- .collect {|k,v| [k.split('_').collect(&:capitalize).join('-'), v]}
20
- .sort
21
- .flatten]
22
+ @headers ||= ::Hash[
23
+ *@env.select { |k,v| k.is_a?(String) && k.start_with?(HTTP_PREFIX) }
24
+ .collect { |k,v| [k.sub(/^#{HTTP_PREFIX}/, ''), v] }
25
+ .collect { |k,v| [k.split('_').collect(&:capitalize).join('-'), v] }
26
+ .sort
27
+ .flatten
28
+ ]
22
29
  end
23
30
 
24
31
  def ip
@@ -1,3 +1,3 @@
1
1
  module Timber
2
- VERSION = "2.0.21"
2
+ VERSION = "2.0.22"
3
3
  end
@@ -0,0 +1,10 @@
1
+ require "spec_helper"
2
+
3
+ describe Timber::Util::Request, :rails_23 => true do
4
+ describe ".headers" do
5
+ it "should ignore symbol keys" do
6
+ req = described_class.new({test: "value"})
7
+ expect(req.headers).to eq({})
8
+ end
9
+ end
10
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.21
4
+ version: 2.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timber Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
11
+ date: 2017-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -243,6 +243,7 @@ files:
243
243
  - spec/timber/log_entry_spec.rb
244
244
  - spec/timber/logger_spec.rb
245
245
  - spec/timber/util/http_event_spec.rb
246
+ - spec/timber/util/request_spec.rb
246
247
  - timber.gemspec
247
248
  homepage: https://github.com/timberio/timber-ruby
248
249
  licenses: []
@@ -300,3 +301,4 @@ test_files:
300
301
  - spec/timber/log_entry_spec.rb
301
302
  - spec/timber/logger_spec.rb
302
303
  - spec/timber/util/http_event_spec.rb
304
+ - spec/timber/util/request_spec.rb