31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/sentry/transport/http_transport.rb', line 31
def send_data(data)
encoding = ""
if should_compress?(data)
data = Zlib.gzip(data)
encoding = GZIP_ENCODING
end
= {
"Content-Type" => CONTENT_TYPE,
"Content-Encoding" => encoding,
"User-Agent" => USER_AGENT
}
=
["X-Sentry-Auth"] = if
response = do_request(endpoint, , data)
if response.code.match?(/\A2\d{2}/)
handle_rate_limited_response(response) if (response)
elsif response.code == "429"
log_debug("the server responded with status 429")
handle_rate_limited_response(response)
else
error_info = "the server responded with status #{response.code}"
error_info += "\nbody: #{response.body}"
error_info += " Error in headers is: #{response['x-sentry-error']}" if response["x-sentry-error"]
raise Sentry::ExternalError, error_info
end
rescue SocketError, *HTTP_ERRORS => e
on_error if respond_to?(:on_error)
raise Sentry::ExternalError.new(e&.message)
end
|