rollbar 0.11.3 → 0.11.4

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: a05a8983a4b7621ec27fb68f6a8181357f709f5b
4
- data.tar.gz: cad9b0ab2cf6ca8a05dcda83aeff733e9c8ee6ad
3
+ metadata.gz: 8082846880731311ecb0f18a70e1beb6db7b186d
4
+ data.tar.gz: c9378f92930c2f40e13cfb587d52d392db3c6800
5
5
  SHA512:
6
- metadata.gz: e63b34f583fd421501c41d60df6f597ee0acd7656704e251a42af46923450140e87759ac1414ff3d64cebe3e906ce2a45dfcd20e4f2ed0f6a6dd974dba01c8e4
7
- data.tar.gz: a034f48d725e87bc5b7013698a5e30e78378fca32aa276558582c72885faafefddcce6442c8a663e6622f9830bbecf3080d220da2eaa1605057dedfb2d4d9f43
6
+ metadata.gz: b16682566ae76dd0ec673427e4e3eac2eec91e9ab87cf47c3803e683464a8dc82baa13c48ac2a94a96488bdcb829752c6ed9d267f480ed5b94b66aa0f8d37c65
7
+ data.tar.gz: ef469ba5168631c3a49a2f775f09e1d0e7c8f742eb7f122e7c47da8d26e8424cdd62da0317ec44cf17718ad9ac845dee12804df46acb331f11026e56f9696f25
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Change Log
2
2
 
3
+ **0.11.4**
4
+ - Respect different proxy headers when building the request url
5
+
3
6
  **0.11.3**
4
7
  - Make sure the environment is valid at item sending time so that it isn't set incorrectly during configuration
5
8
 
@@ -52,12 +52,20 @@ module Rollbar
52
52
  end
53
53
 
54
54
  def rollbar_url(env)
55
- scheme = env['rack.url_scheme']
56
- host = env['HTTP_HOST'] || env['SERVER_NAME']
55
+ scheme = env['HTTP_X_FORWARDED_PROTO'] || env['rack.url_scheme']
56
+
57
+ host = env['HTTP_X_FORWARDED_HOST'] || env['HTTP_HOST'] || env['SERVER_NAME']
57
58
  path = env['ORIGINAL_FULLPATH'] || env['REQUEST_URI']
58
59
  unless path.nil? || path.empty?
59
60
  path = '/' + path.to_s if path.to_s.slice(0, 1) != '/'
60
61
  end
62
+
63
+ port = env['HTTP_X_FORWARDED_PORT']
64
+ if port && !(scheme.downcase == 'http' && port.to_i == 80) && \
65
+ !(scheme.downcase == 'https' && port.to_i == 443) && \
66
+ !(host.include? ':')
67
+ host = host + ':' + port
68
+ end
61
69
 
62
70
  [scheme, '://', host, path].join
63
71
  end
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = "0.11.3"
2
+ VERSION = "0.11.4"
3
3
  end
@@ -159,6 +159,34 @@ describe HomeController do
159
159
 
160
160
  controller.send(:rollbar_request_data)[:url].should == 'http://rollbar.com'
161
161
  end
162
+
163
+ it "should respect forwarded host" do
164
+ req = controller.request
165
+ req.host = '127.0.0.1:8080'
166
+ req.env['HTTP_X_FORWARDED_HOST'] = 'test.com'
167
+
168
+ controller.send(:rollbar_request_data)[:url].should == 'http://test.com'
169
+ end
170
+
171
+ it "should respect forwarded proto" do
172
+ req = controller.request
173
+ req.host = 'rollbar.com'
174
+ req.env['HTTP_X_FORWARDED_PROTO'] = 'https'
175
+
176
+ controller.send(:rollbar_request_data)[:url].should == 'https://rollbar.com'
177
+ end
178
+
179
+ it "should respect forwarded port" do
180
+ req = controller.request
181
+ req.host = '127.0.0.1:8080'
182
+ req.env['HTTP_X_FORWARDED_HOST'] = 'test.com'
183
+ req.env['HTTP_X_FORWARDED_PORT'] = '80'
184
+
185
+ controller.send(:rollbar_request_data)[:url].should == 'http://test.com'
186
+
187
+ req.env['HTTP_X_FORWARDED_PORT'] = '81'
188
+ controller.send(:rollbar_request_data)[:url].should == 'http://test.com:81'
189
+ end
162
190
  end
163
191
 
164
192
  context "rollbar_user_ip" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Rue