prodis / correios-frete

Gem para cálculo de frete utilizando o Web Service dos Correios (http://www.correios.com.br/webservices).
http://prodis.blog.br/correios-frete-gem-para-calculo-de-frete-dos-correios
132 stars 54 forks source link

[Correios::Frete] Correios-Frete Response: HTTP/1.1 407 Proxy Authentication Required #24

Open Ronair opened 7 years ago

Ronair commented 7 years ago

Problema: utilizar a gem em ambiente de desenvolvimento onde tem proxy. Erro: " [Correios::Frete] Correios-Frete Response: HTTP/1.1 407 Proxy Authentication Required .... " Solução: Adicionar no seu arquivo /config/environments/development.rb

module Correios
  module Frete
    class WebService
      def http_request(url)

        uri = URI.parse(url)
        request = Net::HTTP::Get.new(uri.request_uri)
        http = Net::HTTP.new(uri.host, uri.port)
        http.open_timeout = Correios::Frete.request_timeout

        http.proxy_address = 'ip_proxy'
        http.proxy_port = 'port'
        http.proxy_user = 'user'
        http.proxy_pass = 'password'

        http.request(request)
      end
    end
  end
end
prodis commented 7 years ago

@Ronair Thanks for expose your problem and share your fix. 👍 I will keep this issue opened until we have a root solution.

Could you help to implement support for proxy? 😉 We can have something similar to correios-cep gem: https://github.com/prodis/correios-cep#http-proxy