Compare commits

..

No commits in common. "9c765385a5a051408a4c8c38d4d5d1ee41533adb" and "7ed7eec2dc9f40945651fa3ac06452e44d271aaf" have entirely different histories.

19 changed files with 15 additions and 68 deletions

View File

@ -1,11 +0,0 @@
# 0.22.1
## Bugfixes
* `:retries` plugin: fix `HTTPX::Response#response to point to last possible response in the redirection chain.
* `:stream` plugin: Make `HTTPX::Session#request` public (as it is inn the main class) .
* return 100 responses if the request didn't specifically ask for "100-continue" negotiation (via the "expect" header).
## Improvements
Wrap low-level socket errors in a `HTTPX::ConnectionError` exception.

View File

@ -1,5 +0,0 @@
# 0.22.1
## Chore
Checking response class before calling `.status`, as this was being called in some places on error responses, thereby triggering the deprecation warning.

View File

@ -242,8 +242,7 @@ module Faraday
Errno::EHOSTUNREACH,
Errno::EINVAL,
Errno::ENETUNREACH,
Errno::EPIPE,
::HTTPX::ConnectionError => e
Errno::EPIPE => e
raise CONNECTION_FAILED_ERROR, e
end

View File

@ -63,11 +63,7 @@ module HTTPX::Plugins
request_info = extract_request_info(req)
sentry_span.set_description("#{request_info[:method]} #{request_info[:url]}")
if res.is_a?(HTTPX::ErrorResponse)
sentry_span.set_data(:error, res.message)
else
sentry_span.set_data(:status, res.status)
end
sentry_span.set_data(:status, res.status)
sentry_span.set_timestamp(::Sentry.utc_now.to_f)
end

View File

@ -526,14 +526,8 @@ module HTTPX
Errno::EHOSTUNREACH,
Errno::EINVAL,
Errno::ENETUNREACH,
Errno::EPIPE => e
# connect errors, exit gracefully
error = ConnectionError.new(e.message)
error.set_backtrace(e.backtrace)
handle_error(error)
@state = :closed
emit(:close)
rescue TLSError => e
Errno::EPIPE,
TLSError => e
# connect errors, exit gracefully
handle_error(e)
@state = :closed

View File

@ -5,8 +5,6 @@ module HTTPX
class UnsupportedSchemeError < Error; end
class ConnectionError < Error; end
class TimeoutError < Error
attr_reader :timeout

View File

@ -74,13 +74,8 @@ module HTTPX
try_connect
rescue Errno::ECONNREFUSED,
Errno::EADDRNOTAVAIL,
Errno::EHOSTUNREACH,
SocketError => e
if @ip_index <= 0
error = ConnectionError.new(e.message)
error.set_backtrace(e.backtrace)
raise error
end
Errno::EHOSTUNREACH => e
raise e if @ip_index <= 0
log { "failed connecting to #{@ip} (#{e.message}), trying next..." }
@ip_index -= 1

View File

@ -46,8 +46,6 @@ module HTTPX
probe_response = wrap { super(request).first }
return probe_response unless probe_response.is_a?(Response)
if probe_response.status == 401 && digest.can_authenticate?(probe_response.headers["www-authenticate"])
request.transition(:idle)
request.headers["authorization"] = digest.authenticate(request, probe_response.headers["www-authenticate"])

View File

@ -50,8 +50,7 @@ module HTTPX
end
def response=(response)
if response.is_a?(Response) &&
response.status == 100 &&
if response && response.status == 100 &&
!@headers.key?("expect") &&
(@state == :body || @state == :done)
@ -93,7 +92,7 @@ module HTTPX
response = @responses.delete(request)
return unless response
if response.is_a?(Response) && response.status == 417 && request.headers.key?("expect")
if response.status == 417 && request.headers.key?("expect")
response.close
request.headers.delete("expect")
request.transition(:idle)

View File

@ -44,7 +44,6 @@ module HTTPX
max_redirects = redirect_request.max_redirects
return response unless response.is_a?(Response)
return response unless REDIRECT_STATUS.include?(response.status) && response.headers.key?("location")
return response unless max_redirects.positive?
@ -122,12 +121,6 @@ module HTTPX
@redirect_request || self
end
def response
return super unless @redirect_request
@redirect_request.response
end
def max_redirects
@options.max_redirects || MAX_REDIRECTS
end

View File

@ -39,8 +39,6 @@ module HTTPX
request.headers["authorization"] = ntlm.negotiate
probe_response = wrap { super(request).first }
return probe_response unless probe_response.is_a?(Response)
if probe_response.status == 401 && ntlm.can_authenticate?(probe_response.headers["www-authenticate"])
request.transition(:idle)
request.headers["authorization"] = ntlm.authenticate(request, probe_response.headers["www-authenticate"])

View File

@ -23,7 +23,6 @@ module HTTPX
response = super
if response &&
response.is_a?(Response) &&
response.status == 407 &&
!request.headers.key?("proxy-authorization") &&
response.headers.key?("proxy-authenticate")
@ -114,14 +113,13 @@ module HTTPX
def __http_on_connect(request, response)
@inflight -= 1
if response.is_a?(Response) && response.status == 200
if response.status == 200
req = @pending.first
request_uri = req.uri
@io = ProxySSL.new(@io, request_uri, @options)
transition(:connected)
throw(:called)
elsif response.is_a?(Response) &&
response.status == 407 &&
elsif response.status == 407 &&
!request.headers.key?("proxy-authorization") &&
@options.proxy.can_authenticate?(response.headers["proxy-authenticate"])

View File

@ -23,8 +23,6 @@ module HTTPX
end
def retry_on_rate_limited_response(response)
return false unless response.is_a?(Response)
status = response.status
RATE_LIMIT_CODES.include?(status)

View File

@ -23,7 +23,6 @@ module HTTPX
Parser::Error,
TLSError,
TimeoutError,
ConnectionError,
Connection::HTTP2::GoawayError,
].freeze
DEFAULT_JITTER = ->(interval) { interval * (0.5 * (1 + rand)) }

View File

@ -95,6 +95,8 @@ module HTTPX
#
module Stream
module InstanceMethods
private
def request(*args, stream: false, **options)
return super(*args, **options) unless stream

View File

@ -35,9 +35,7 @@ module HTTPX
response = super
if response
return response unless response.is_a?(Response)
return response unless response.headers.key?("upgrade")
return response unless response.respond_to?(:headers) && response.headers.key?("upgrade")
upgrade_protocol = response.headers["upgrade"].split(/ *, */).first

View File

@ -32,8 +32,6 @@ module HTTPX
"</D:lockinfo>"
response = request(:lock, path, headers: headers, xml: xml)
return response unless response.is_a?(Response)
return response unless blk && response.status == 200
lock_token = response.headers["lock-token"]

View File

@ -86,7 +86,7 @@ module HTTPX
def response=(response)
return unless response
if response.is_a?(Response) && response.status == 100 && @headers.key?("expect")
if response.is_a?(Response) && response.status == 100
@informational_status = response.status
return
end

View File

@ -1,5 +1,5 @@
# frozen_string_literal: true
module HTTPX
VERSION = "0.22.2"
VERSION = "0.22.0"
end