mirror of
				https://github.com/HoneyryderChuck/httpx.git
				synced 2025-11-04 00:01:41 -05:00 
			
		
		
		
	When: 1. the proxy is autodetected from `http_proxy` etc. variables; 2. a request is made which bypasses the proxy (e.g. to an authority in `no_proxy`); 3. this request fails with one of `Proxy::PROXY_ERRORS` (timeout or a system error) the `fetch_response` method tried to access the proxy URIs array which isn't initialized by `proxy_options`. This change fixes the `proxy_error?` check to avoid the issue.
		
			
				
	
	
		
			37 lines
		
	
	
		
			795 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			795 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
# frozen_string_literal: true
 | 
						|
 | 
						|
require "test_helper"
 | 
						|
require "support/http_helpers"
 | 
						|
require "webmock/minitest"
 | 
						|
require "httpx/adapters/webmock"
 | 
						|
 | 
						|
class Bug_1_3_1_Test < Minitest::Test
 | 
						|
  include HTTPHelpers
 | 
						|
 | 
						|
  def test_plugin_http_webmock_next_proxy
 | 
						|
    exception_class = Class.new(IOError)
 | 
						|
    stub_exception = stub_http_request(:any, "https://#{httpbin}/get").to_raise(exception_class.new("exception message"))
 | 
						|
 | 
						|
    HTTPX.plugin(SessionWithPool).plugin(ProxyResponseDetector).plugin(:proxy).wrap do |http|
 | 
						|
      http.get("https://#{httpbin}/get")
 | 
						|
      assert_requested(stub_exception)
 | 
						|
    end
 | 
						|
  end
 | 
						|
 | 
						|
  private
 | 
						|
 | 
						|
  def scheme
 | 
						|
    "http://"
 | 
						|
  end
 | 
						|
 | 
						|
  def setup
 | 
						|
    WebMock.enable!
 | 
						|
    WebMock.disable_net_connect!
 | 
						|
  end
 | 
						|
 | 
						|
  def teardown
 | 
						|
    WebMock.allow_net_connect!
 | 
						|
    WebMock.disable!
 | 
						|
  end
 | 
						|
end
 |