Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased

### Internal

- Factor out do_request in HTTP transport ([#2662](https://github.com/getsentry/sentry-ruby/pull/2662))

## 5.26.0

### Feature
Expand Down
14 changes: 9 additions & 5 deletions sentry-ruby/lib/sentry/transport/http_transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ def send_data(data)
auth_header = generate_auth_header
headers["X-Sentry-Auth"] = auth_header if auth_header

response = conn.start do |http|
request = ::Net::HTTP::Post.new(endpoint, headers)
request.body = data
http.request(request)
end
response = do_request(endpoint, headers, data)

if response.code.match?(/\A2\d{2}/)
handle_rate_limited_response(response) if has_rate_limited_header?(response)
Expand Down Expand Up @@ -111,6 +107,14 @@ def conn
connection
end

def do_request(endpoint, headers, body)
conn.start do |http|
request = ::Net::HTTP::Post.new(endpoint, headers)
request.body = body
http.request(request)
end
end

private

def has_rate_limited_header?(headers)
Expand Down
Loading