Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy option #127

Open
paratskyi opened this issue Oct 10, 2023 · 0 comments
Open

Add proxy option #127

paratskyi opened this issue Oct 10, 2023 · 0 comments

Comments

@paratskyi
Copy link

paratskyi commented Oct 10, 2023

After bumping valvat from 1.1.5 to 1.4.0, we cannot set a proxy for the Net::HTTP request. My suggestion is to add proxy option to http option to set proxy for the http client.

Fixed with patch and options

{ open_timeout: 10, read_timeout: 10, proxy: { p_addr: 'proxy_address', p_port: 'proxy_port'} }
class Valvat
  class Lookup
    class Base
      private

      def send_request(uri)
        proxy_options = @options[:http].delete(:proxy)

        if proxy_options
          proxy_args = proxy_options.values_at(:p_addr, :p_port, :p_user, :p_pass).compact
          request = build_request(uri)
          Net::HTTP.start(uri.host, uri.port, *proxy_args, options_for(uri)) do |http|
            http.request(request)
          end
        else
          super
        end
      end
    end
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant