Compare commits

...

6 Commits

Author SHA1 Message Date
HoneyryderChuck
325f7141c8 promoting HTTPX::Response::Body#encoding to public API 2022-12-21 00:46:14 +00:00
HoneyryderChuck
d09b107314 dealing with datadog breaking change better 2022-12-21 00:45:26 +00:00
HoneyryderChuck
e301811196 fixed datadog recent change for error tag 2022-12-21 00:31:42 +00:00
HoneyryderChuck
9842511594 more linting... 2022-12-20 22:58:57 +00:00
HoneyryderChuck
d629402245 linting 2022-12-20 22:28:07 +00:00
HoneyryderChuck
9b89cb3331 commenting extensions 2022-12-20 22:27:59 +00:00
9 changed files with 27 additions and 11 deletions

View File

@ -50,11 +50,11 @@ rdoc_opts = ["--line-numbers", "--title", "HTTPX: An HTTP client library for rub
begin
gem "hanna-nouveau"
rdoc_opts.concat(["-f", "hanna"])
rdoc_opts.push("-f", "hanna")
rescue Gem::LoadError
end
rdoc_opts.concat(["--main", "README.md"])
rdoc_opts.push("--main", "README.md")
RDOC_FILES = %w[README.md lib/**/*.rb] + Dir["doc/*.rdoc"] + Dir["doc/release_notes/*.md"]
RDoc::Task.new do |rdoc|

View File

@ -197,14 +197,21 @@ class DatadogTest < Minitest::Test
assert span.get_tag("out.port") == "80"
assert span.get_tag("http.method") == verb
assert span.get_tag("http.url") == uri.path
error_tag = if defined?(::DDTrace) && ::DDTrace::VERSION::STRING >= "1.8.0"
"error.message"
else
"error.msg"
end
if error
assert span.get_tag("error.type") == error
assert !span.get_tag("error.msg").nil?
assert !span.get_tag(error_tag).nil?
assert span.status == 1
elsif response.status >= 400
assert span.get_tag("http.status_code") == response.status.to_s
assert span.get_tag("error.type") == "HTTPX::HTTPError"
assert !span.get_tag("error.msg").nil?
assert !span.get_tag(error_tag).nil?
assert span.status == 1
else
assert span.status.zero?

View File

@ -1,6 +1,6 @@
# frozen_string_literal: true
if defined?(::DDTrace) && ::DDTrace::VERSION::STRING >= "1.0.0"
if defined?(DDTrace) && DDTrace::VERSION::STRING >= "1.0.0"
require "datadog/tracing/contrib/integration"
require "datadog/tracing/contrib/configuration/settings"
require "datadog/tracing/contrib/patcher"

View File

@ -95,7 +95,7 @@ module HTTPX::Plugins
end
Sentry.register_patch do
sentry_session = ::HTTPX.plugin(HTTPX::Plugins::Sentry)
sentry_session = HTTPX.plugin(HTTPX::Plugins::Sentry)
HTTPX.send(:remove_const, :Session)
HTTPX.send(:const_set, :Session, sentry_session.class)

View File

@ -55,6 +55,7 @@ module HTTPX
end
module NumericExtensions
# Ruby 2.4 backport
refine Numeric do
def infinite?
self == Float::INFINITY
@ -64,6 +65,7 @@ module HTTPX
module StringExtensions
refine String do
# Ruby 2.5 backport
def delete_suffix!(suffix)
suffix = Backports.coerce_to_str(suffix)
chomp! if frozen?
@ -80,6 +82,7 @@ module HTTPX
module HashExtensions
refine Hash do
# Ruby 2.4 backport
def compact
h = {}
each do |key, value|
@ -93,7 +96,7 @@ module HTTPX
module ArrayExtensions
module FilterMap
refine Array do
# Ruby 2.7 backport
def filter_map
return to_enum(:filter_map) unless block_given?
@ -107,6 +110,7 @@ module HTTPX
module Sum
refine Array do
# Ruby 2.6 backport
def sum(accumulator = 0, &block)
values = block_given? ? map(&block) : self
values.inject(accumulator, :+)
@ -116,6 +120,7 @@ module HTTPX
module Intersect
refine Array do
# Ruby 3.1 backport
def intersect?(arr)
if size < arr.size
smaller = self
@ -130,6 +135,7 @@ module HTTPX
module IOExtensions
refine IO do
# Ruby 2.3 backport
# provides a fallback for rubies where IO#wait isn't implemented,
# but IO#wait_readable and IO#wait_writable are.
def wait(timeout = nil, _mode = :read_write)
@ -144,6 +150,7 @@ module HTTPX
module RegexpExtensions
refine(Regexp) do
# Ruby 2.4 backport
def match?(*args)
!match(*args).nil?
end
@ -151,6 +158,7 @@ module HTTPX
end
module URIExtensions
# uri 0.11 backport, ships with ruby 3.1
refine URI::Generic do
def non_ascii_hostname
@non_ascii_hostname

View File

@ -128,6 +128,8 @@ module HTTPX
end
class Body
attr_reader :encoding
def initialize(response, options)
@response = response
@headers = response.headers

View File

@ -38,7 +38,6 @@ module HTTPX::Transcoder
begin
require "nokogiri"
# rubocop:disable Lint/DuplicateMethods
def decode(response)
content_type = response.content_type.mime_type
@ -51,7 +50,6 @@ module HTTPX::Transcoder
raise HTTPX::Error, "\"nokogiri\" is required in order to decode XML"
end
end
# rubocop:enable Lint/DuplicateMethods
end
register "xml", Xml
end

View File

@ -48,13 +48,14 @@ module HTTPX
include _ToS
include _ToStr
attr_reader encoding: String
@response: Response
@headers: Headers
@options: Options
@state: :idle | :memory | :buffer | :closed
@threshold_size: Integer
@window_size: Integer
@encoding: String
@length: Integer
@buffer: StringIO | Tempfile | nil

View File

@ -3,7 +3,7 @@
Signal.trap("USR2") do
warn "starting..."
Thread.list.each do |thread|
warn "Thread TID-#{(thread.object_id ^ ::Process.pid).to_s(36)} #{thread.name}"
warn "Thread TID-#{(thread.object_id ^ Process.pid).to_s(36)} #{thread.name}"
warn thread.backtrace || "<no backtrace available>"
end
end