Skip to content

Commit 818b6c0

Browse files
authored
Factor out do_request in HTTP transport (#2662)
1 parent 92cb875 commit 818b6c0

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Unreleased
2+
3+
### Internal
4+
5+
- Factor out do_request in HTTP transport ([#2662](https://github.com/getsentry/sentry-ruby/pull/2662))
6+
17
## 5.26.0
28

39
### Feature

sentry-ruby/lib/sentry/transport/http_transport.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ def send_data(data)
4545
auth_header = generate_auth_header
4646
headers["X-Sentry-Auth"] = auth_header if auth_header
4747

48-
response = conn.start do |http|
49-
request = ::Net::HTTP::Post.new(endpoint, headers)
50-
request.body = data
51-
http.request(request)
52-
end
48+
response = do_request(endpoint, headers, data)
5349

5450
if response.code.match?(/\A2\d{2}/)
5551
handle_rate_limited_response(response) if has_rate_limited_header?(response)
@@ -111,6 +107,14 @@ def conn
111107
connection
112108
end
113109

110+
def do_request(endpoint, headers, body)
111+
conn.start do |http|
112+
request = ::Net::HTTP::Post.new(endpoint, headers)
113+
request.body = body
114+
http.request(request)
115+
end
116+
end
117+
114118
private
115119

116120
def has_rate_limited_header?(headers)

0 commit comments

Comments
 (0)