I have a Ruby code:
require 'net/http'
url = "https://stackoverflow.com/questions/65798852/how-do-i-set-an-electron-variable-at-compile-time"
response = Net::HTTP.get_response(url, '/')
Which produces errors:
getaddrinfo: nodename nor servname provided, or not known (SocketError)
and
Failed to open TCP connection to https://stackoverflow.com/questions/65798852/how-do-i-set-an-electron-variable-at-compile-time:80 (getaddrinfo: nodename nor servname provided, or not known) (SocketError)
But it works perfectly with uri:
require 'net/http'
url = "https://stackoverflow.com/questions/65798852/how-do-i-set-an-electron-variable-at-compile-time"
uri = URI(url)
response = Net::HTTP.get_response(uri)
So, could anyone explain what is the difference, why it works so, and what is so special about URI?
question from:
https://stackoverflow.com/questions/65952596/ruby-net-http-get-does-not-work-with-urls-but-works-with-uris-why 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…