mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-07-17 00:00:38 -04:00
Compare commits
10 Commits
7ed7eec2dc
...
9c765385a5
Author | SHA1 | Date | |
---|---|---|---|
|
9c765385a5 | ||
|
06274364ef | ||
|
42a35e65d2 | ||
|
9f224ae389 | ||
|
6723fca484 | ||
|
73326672f4 | ||
|
d86b780d1a | ||
|
2cbcd72722 | ||
|
5937e36f03 | ||
|
f38573e4e0 |
11
doc/release_notes/0_22_1.md
Normal file
11
doc/release_notes/0_22_1.md
Normal file
@ -0,0 +1,11 @@
|
||||
# 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.
|
5
doc/release_notes/0_22_2.md
Normal file
5
doc/release_notes/0_22_2.md
Normal file
@ -0,0 +1,5 @@
|
||||
# 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,7 +242,8 @@ module Faraday
|
||||
Errno::EHOSTUNREACH,
|
||||
Errno::EINVAL,
|
||||
Errno::ENETUNREACH,
|
||||
Errno::EPIPE => e
|
||||
Errno::EPIPE,
|
||||
::HTTPX::ConnectionError => e
|
||||
raise CONNECTION_FAILED_ERROR, e
|
||||
end
|
||||
|
||||
|
@ -63,7 +63,11 @@ module HTTPX::Plugins
|
||||
|
||||
request_info = extract_request_info(req)
|
||||
sentry_span.set_description("#{request_info[:method]} #{request_info[:url]}")
|
||||
sentry_span.set_data(:status, res.status)
|
||||
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_timestamp(::Sentry.utc_now.to_f)
|
||||
end
|
||||
|
||||
|
@ -526,8 +526,14 @@ module HTTPX
|
||||
Errno::EHOSTUNREACH,
|
||||
Errno::EINVAL,
|
||||
Errno::ENETUNREACH,
|
||||
Errno::EPIPE,
|
||||
TLSError => e
|
||||
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
|
||||
# connect errors, exit gracefully
|
||||
handle_error(e)
|
||||
@state = :closed
|
||||
|
@ -5,6 +5,8 @@ module HTTPX
|
||||
|
||||
class UnsupportedSchemeError < Error; end
|
||||
|
||||
class ConnectionError < Error; end
|
||||
|
||||
class TimeoutError < Error
|
||||
attr_reader :timeout
|
||||
|
||||
|
@ -74,8 +74,13 @@ module HTTPX
|
||||
try_connect
|
||||
rescue Errno::ECONNREFUSED,
|
||||
Errno::EADDRNOTAVAIL,
|
||||
Errno::EHOSTUNREACH => e
|
||||
raise e if @ip_index <= 0
|
||||
Errno::EHOSTUNREACH,
|
||||
SocketError => e
|
||||
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..." }
|
||||
@ip_index -= 1
|
||||
|
@ -46,6 +46,8 @@ 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"])
|
||||
|
@ -50,7 +50,8 @@ module HTTPX
|
||||
end
|
||||
|
||||
def response=(response)
|
||||
if response && response.status == 100 &&
|
||||
if response.is_a?(Response) &&
|
||||
response.status == 100 &&
|
||||
!@headers.key?("expect") &&
|
||||
(@state == :body || @state == :done)
|
||||
|
||||
@ -92,7 +93,7 @@ module HTTPX
|
||||
response = @responses.delete(request)
|
||||
return unless response
|
||||
|
||||
if response.status == 417 && request.headers.key?("expect")
|
||||
if response.is_a?(Response) && response.status == 417 && request.headers.key?("expect")
|
||||
response.close
|
||||
request.headers.delete("expect")
|
||||
request.transition(:idle)
|
||||
|
@ -44,6 +44,7 @@ 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?
|
||||
|
||||
@ -121,6 +122,12 @@ 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
|
||||
|
@ -39,6 +39,8 @@ 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"])
|
||||
|
@ -23,6 +23,7 @@ module HTTPX
|
||||
response = super
|
||||
|
||||
if response &&
|
||||
response.is_a?(Response) &&
|
||||
response.status == 407 &&
|
||||
!request.headers.key?("proxy-authorization") &&
|
||||
response.headers.key?("proxy-authenticate")
|
||||
@ -113,13 +114,14 @@ module HTTPX
|
||||
|
||||
def __http_on_connect(request, response)
|
||||
@inflight -= 1
|
||||
if response.status == 200
|
||||
if response.is_a?(Response) && response.status == 200
|
||||
req = @pending.first
|
||||
request_uri = req.uri
|
||||
@io = ProxySSL.new(@io, request_uri, @options)
|
||||
transition(:connected)
|
||||
throw(:called)
|
||||
elsif response.status == 407 &&
|
||||
elsif response.is_a?(Response) &&
|
||||
response.status == 407 &&
|
||||
!request.headers.key?("proxy-authorization") &&
|
||||
@options.proxy.can_authenticate?(response.headers["proxy-authenticate"])
|
||||
|
||||
|
@ -23,6 +23,8 @@ 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)
|
||||
|
@ -23,6 +23,7 @@ module HTTPX
|
||||
Parser::Error,
|
||||
TLSError,
|
||||
TimeoutError,
|
||||
ConnectionError,
|
||||
Connection::HTTP2::GoawayError,
|
||||
].freeze
|
||||
DEFAULT_JITTER = ->(interval) { interval * (0.5 * (1 + rand)) }
|
||||
|
@ -95,8 +95,6 @@ module HTTPX
|
||||
#
|
||||
module Stream
|
||||
module InstanceMethods
|
||||
private
|
||||
|
||||
def request(*args, stream: false, **options)
|
||||
return super(*args, **options) unless stream
|
||||
|
||||
|
@ -35,7 +35,9 @@ module HTTPX
|
||||
response = super
|
||||
|
||||
if response
|
||||
return response unless response.respond_to?(:headers) && response.headers.key?("upgrade")
|
||||
return response unless response.is_a?(Response)
|
||||
|
||||
return response unless response.headers.key?("upgrade")
|
||||
|
||||
upgrade_protocol = response.headers["upgrade"].split(/ *, */).first
|
||||
|
||||
|
@ -32,6 +32,8 @@ 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"]
|
||||
|
@ -86,7 +86,7 @@ module HTTPX
|
||||
def response=(response)
|
||||
return unless response
|
||||
|
||||
if response.is_a?(Response) && response.status == 100
|
||||
if response.is_a?(Response) && response.status == 100 && @headers.key?("expect")
|
||||
@informational_status = response.status
|
||||
return
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module HTTPX
|
||||
VERSION = "0.22.0"
|
||||
VERSION = "0.22.2"
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user