httpx/test/support/proxy_response_detector.rb
HoneyryderChuck 43016795f3 introducing the :no_proxy option
can be passed in the `:proxy` option hash, and receives domains, as
strings, which requests should not go through the proxy.
2022-08-05 22:37:52 +01:00

30 lines
524 B
Ruby

# frozen_string_literal: true
module ProxyResponseDetector
module RequestMethods
attr_writer :proxied
def proxied?
@proxied
end
end
module ResponseMethods
def proxied?
@request.proxied?
end
end
module ConnectionMethods
def send(request)
return super unless @options.respond_to?(:proxy) && @options.proxy
proxy_uri = URI(@options.proxy.uri)
request.proxied = @origin.host == proxy_uri.host && @origin.port == proxy_uri.port
super
end
end
end