mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-07-18 00:00:50 -04:00
Compare commits
No commits in common. "9c765385a5a051408a4c8c38d4d5d1ee41533adb" and "7ed7eec2dc9f40945651fa3ac06452e44d271aaf" have entirely different histories.
9c765385a5
...
7ed7eec2dc
@ -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.
|
|
@ -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.
|
|
@ -242,8 +242,7 @@ module Faraday
|
|||||||
Errno::EHOSTUNREACH,
|
Errno::EHOSTUNREACH,
|
||||||
Errno::EINVAL,
|
Errno::EINVAL,
|
||||||
Errno::ENETUNREACH,
|
Errno::ENETUNREACH,
|
||||||
Errno::EPIPE,
|
Errno::EPIPE => e
|
||||||
::HTTPX::ConnectionError => e
|
|
||||||
raise CONNECTION_FAILED_ERROR, e
|
raise CONNECTION_FAILED_ERROR, e
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,11 +63,7 @@ module HTTPX::Plugins
|
|||||||
|
|
||||||
request_info = extract_request_info(req)
|
request_info = extract_request_info(req)
|
||||||
sentry_span.set_description("#{request_info[:method]} #{request_info[:url]}")
|
sentry_span.set_description("#{request_info[:method]} #{request_info[:url]}")
|
||||||
if res.is_a?(HTTPX::ErrorResponse)
|
sentry_span.set_data(:status, res.status)
|
||||||
sentry_span.set_data(:error, res.message)
|
|
||||||
else
|
|
||||||
sentry_span.set_data(:status, res.status)
|
|
||||||
end
|
|
||||||
sentry_span.set_timestamp(::Sentry.utc_now.to_f)
|
sentry_span.set_timestamp(::Sentry.utc_now.to_f)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -526,14 +526,8 @@ module HTTPX
|
|||||||
Errno::EHOSTUNREACH,
|
Errno::EHOSTUNREACH,
|
||||||
Errno::EINVAL,
|
Errno::EINVAL,
|
||||||
Errno::ENETUNREACH,
|
Errno::ENETUNREACH,
|
||||||
Errno::EPIPE => e
|
Errno::EPIPE,
|
||||||
# connect errors, exit gracefully
|
TLSError => e
|
||||||
error = ConnectionError.new(e.message)
|
|
||||||
error.set_backtrace(e.backtrace)
|
|
||||||
handle_error(error)
|
|
||||||
@state = :closed
|
|
||||||
emit(:close)
|
|
||||||
rescue TLSError => e
|
|
||||||
# connect errors, exit gracefully
|
# connect errors, exit gracefully
|
||||||
handle_error(e)
|
handle_error(e)
|
||||||
@state = :closed
|
@state = :closed
|
||||||
|
@ -5,8 +5,6 @@ module HTTPX
|
|||||||
|
|
||||||
class UnsupportedSchemeError < Error; end
|
class UnsupportedSchemeError < Error; end
|
||||||
|
|
||||||
class ConnectionError < Error; end
|
|
||||||
|
|
||||||
class TimeoutError < Error
|
class TimeoutError < Error
|
||||||
attr_reader :timeout
|
attr_reader :timeout
|
||||||
|
|
||||||
|
@ -74,13 +74,8 @@ module HTTPX
|
|||||||
try_connect
|
try_connect
|
||||||
rescue Errno::ECONNREFUSED,
|
rescue Errno::ECONNREFUSED,
|
||||||
Errno::EADDRNOTAVAIL,
|
Errno::EADDRNOTAVAIL,
|
||||||
Errno::EHOSTUNREACH,
|
Errno::EHOSTUNREACH => e
|
||||||
SocketError => e
|
raise e if @ip_index <= 0
|
||||||
if @ip_index <= 0
|
|
||||||
error = ConnectionError.new(e.message)
|
|
||||||
error.set_backtrace(e.backtrace)
|
|
||||||
raise error
|
|
||||||
end
|
|
||||||
|
|
||||||
log { "failed connecting to #{@ip} (#{e.message}), trying next..." }
|
log { "failed connecting to #{@ip} (#{e.message}), trying next..." }
|
||||||
@ip_index -= 1
|
@ip_index -= 1
|
||||||
|
@ -46,8 +46,6 @@ module HTTPX
|
|||||||
|
|
||||||
probe_response = wrap { super(request).first }
|
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"])
|
if probe_response.status == 401 && digest.can_authenticate?(probe_response.headers["www-authenticate"])
|
||||||
request.transition(:idle)
|
request.transition(:idle)
|
||||||
request.headers["authorization"] = digest.authenticate(request, probe_response.headers["www-authenticate"])
|
request.headers["authorization"] = digest.authenticate(request, probe_response.headers["www-authenticate"])
|
||||||
|
@ -50,8 +50,7 @@ module HTTPX
|
|||||||
end
|
end
|
||||||
|
|
||||||
def response=(response)
|
def response=(response)
|
||||||
if response.is_a?(Response) &&
|
if response && response.status == 100 &&
|
||||||
response.status == 100 &&
|
|
||||||
!@headers.key?("expect") &&
|
!@headers.key?("expect") &&
|
||||||
(@state == :body || @state == :done)
|
(@state == :body || @state == :done)
|
||||||
|
|
||||||
@ -93,7 +92,7 @@ module HTTPX
|
|||||||
response = @responses.delete(request)
|
response = @responses.delete(request)
|
||||||
return unless response
|
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
|
response.close
|
||||||
request.headers.delete("expect")
|
request.headers.delete("expect")
|
||||||
request.transition(:idle)
|
request.transition(:idle)
|
||||||
|
@ -44,7 +44,6 @@ module HTTPX
|
|||||||
|
|
||||||
max_redirects = redirect_request.max_redirects
|
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 REDIRECT_STATUS.include?(response.status) && response.headers.key?("location")
|
||||||
return response unless max_redirects.positive?
|
return response unless max_redirects.positive?
|
||||||
|
|
||||||
@ -122,12 +121,6 @@ module HTTPX
|
|||||||
@redirect_request || self
|
@redirect_request || self
|
||||||
end
|
end
|
||||||
|
|
||||||
def response
|
|
||||||
return super unless @redirect_request
|
|
||||||
|
|
||||||
@redirect_request.response
|
|
||||||
end
|
|
||||||
|
|
||||||
def max_redirects
|
def max_redirects
|
||||||
@options.max_redirects || MAX_REDIRECTS
|
@options.max_redirects || MAX_REDIRECTS
|
||||||
end
|
end
|
||||||
|
@ -39,8 +39,6 @@ module HTTPX
|
|||||||
request.headers["authorization"] = ntlm.negotiate
|
request.headers["authorization"] = ntlm.negotiate
|
||||||
probe_response = wrap { super(request).first }
|
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"])
|
if probe_response.status == 401 && ntlm.can_authenticate?(probe_response.headers["www-authenticate"])
|
||||||
request.transition(:idle)
|
request.transition(:idle)
|
||||||
request.headers["authorization"] = ntlm.authenticate(request, probe_response.headers["www-authenticate"])
|
request.headers["authorization"] = ntlm.authenticate(request, probe_response.headers["www-authenticate"])
|
||||||
|
@ -23,7 +23,6 @@ module HTTPX
|
|||||||
response = super
|
response = super
|
||||||
|
|
||||||
if response &&
|
if response &&
|
||||||
response.is_a?(Response) &&
|
|
||||||
response.status == 407 &&
|
response.status == 407 &&
|
||||||
!request.headers.key?("proxy-authorization") &&
|
!request.headers.key?("proxy-authorization") &&
|
||||||
response.headers.key?("proxy-authenticate")
|
response.headers.key?("proxy-authenticate")
|
||||||
@ -114,14 +113,13 @@ module HTTPX
|
|||||||
|
|
||||||
def __http_on_connect(request, response)
|
def __http_on_connect(request, response)
|
||||||
@inflight -= 1
|
@inflight -= 1
|
||||||
if response.is_a?(Response) && response.status == 200
|
if response.status == 200
|
||||||
req = @pending.first
|
req = @pending.first
|
||||||
request_uri = req.uri
|
request_uri = req.uri
|
||||||
@io = ProxySSL.new(@io, request_uri, @options)
|
@io = ProxySSL.new(@io, request_uri, @options)
|
||||||
transition(:connected)
|
transition(:connected)
|
||||||
throw(:called)
|
throw(:called)
|
||||||
elsif response.is_a?(Response) &&
|
elsif response.status == 407 &&
|
||||||
response.status == 407 &&
|
|
||||||
!request.headers.key?("proxy-authorization") &&
|
!request.headers.key?("proxy-authorization") &&
|
||||||
@options.proxy.can_authenticate?(response.headers["proxy-authenticate"])
|
@options.proxy.can_authenticate?(response.headers["proxy-authenticate"])
|
||||||
|
|
||||||
|
@ -23,8 +23,6 @@ module HTTPX
|
|||||||
end
|
end
|
||||||
|
|
||||||
def retry_on_rate_limited_response(response)
|
def retry_on_rate_limited_response(response)
|
||||||
return false unless response.is_a?(Response)
|
|
||||||
|
|
||||||
status = response.status
|
status = response.status
|
||||||
|
|
||||||
RATE_LIMIT_CODES.include?(status)
|
RATE_LIMIT_CODES.include?(status)
|
||||||
|
@ -23,7 +23,6 @@ module HTTPX
|
|||||||
Parser::Error,
|
Parser::Error,
|
||||||
TLSError,
|
TLSError,
|
||||||
TimeoutError,
|
TimeoutError,
|
||||||
ConnectionError,
|
|
||||||
Connection::HTTP2::GoawayError,
|
Connection::HTTP2::GoawayError,
|
||||||
].freeze
|
].freeze
|
||||||
DEFAULT_JITTER = ->(interval) { interval * (0.5 * (1 + rand)) }
|
DEFAULT_JITTER = ->(interval) { interval * (0.5 * (1 + rand)) }
|
||||||
|
@ -95,6 +95,8 @@ module HTTPX
|
|||||||
#
|
#
|
||||||
module Stream
|
module Stream
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
|
private
|
||||||
|
|
||||||
def request(*args, stream: false, **options)
|
def request(*args, stream: false, **options)
|
||||||
return super(*args, **options) unless stream
|
return super(*args, **options) unless stream
|
||||||
|
|
||||||
|
@ -35,9 +35,7 @@ module HTTPX
|
|||||||
response = super
|
response = super
|
||||||
|
|
||||||
if response
|
if response
|
||||||
return response unless response.is_a?(Response)
|
return response unless response.respond_to?(:headers) && response.headers.key?("upgrade")
|
||||||
|
|
||||||
return response unless response.headers.key?("upgrade")
|
|
||||||
|
|
||||||
upgrade_protocol = response.headers["upgrade"].split(/ *, */).first
|
upgrade_protocol = response.headers["upgrade"].split(/ *, */).first
|
||||||
|
|
||||||
|
@ -32,8 +32,6 @@ module HTTPX
|
|||||||
"</D:lockinfo>"
|
"</D:lockinfo>"
|
||||||
response = request(:lock, path, headers: headers, xml: xml)
|
response = request(:lock, path, headers: headers, xml: xml)
|
||||||
|
|
||||||
return response unless response.is_a?(Response)
|
|
||||||
|
|
||||||
return response unless blk && response.status == 200
|
return response unless blk && response.status == 200
|
||||||
|
|
||||||
lock_token = response.headers["lock-token"]
|
lock_token = response.headers["lock-token"]
|
||||||
|
@ -86,7 +86,7 @@ module HTTPX
|
|||||||
def response=(response)
|
def response=(response)
|
||||||
return unless 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
|
@informational_status = response.status
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module HTTPX
|
module HTTPX
|
||||||
VERSION = "0.22.2"
|
VERSION = "0.22.0"
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user