Skip to content

Commit 9a0d5ea

Browse files
committed
Fix POSTing to prefixed Sentry servers. Close #140
1 parent 8aede7e commit 9a0d5ea

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/raven/transports/http.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
require 'raven/transports'
44
require 'raven/error'
5+
require 'pry'
56

67
module Raven
78
module Transports
89
class HTTP < Transport
910

1011
def send(auth_header, data, options = {})
1112
project_id = self.configuration[:project_id]
12-
response = conn.post "/api/#{project_id}/store/" do |req|
13+
path = self.configuration[:path].gsub('/sentry', '') + "/"
14+
15+
response = conn.post "#{path}api/#{project_id}/store/" do |req|
1316
req.headers['Content-Type'] = options[:content_type]
1417
req.headers['X-Sentry-Auth'] = auth_header
1518
req.body = data

spec/raven/integration_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@
2121

2222
end
2323

24+
example "posting an exception to a prefixed DSN" do
25+
26+
stubs = Faraday::Adapter::Test::Stubs.new do |stub|
27+
stub.post('/prefix/api/42/store/') { [200, {}, 'ok'] }
28+
end
29+
30+
Raven.configure do |config|
31+
config.server = 'http://12345:67890@sentry.localdomain/prefix/sentry/42'
32+
config.environments = ["test"]
33+
config.current_environment = "test"
34+
config.http_adapter = [:test, stubs]
35+
end
36+
37+
Raven.capture_exception(build_exception)
38+
39+
stubs.verify_stubbed_calls
40+
end
41+
2442
example "hitting quota limit shouldn't swallow exception" do
2543

2644
stubs = Faraday::Adapter::Test::Stubs.new do |stub|

0 commit comments

Comments
 (0)