{"action":"created","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/5027","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/5027/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/5027/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/5027/events","html_url":"https://github.com/crystal-lang/crystal/issues/5027","id":260041834,"number":5027,"title":"HTTP::Client.new(\"https://example.com\").port == 80","user":{"login":"timolehto","id":491473,"avatar_url":"https://avatars3.githubusercontent.com/u/491473?v=4","gravatar_id":"","url":"https://api.github.com/users/timolehto","html_url":"https://github.com/timolehto","followers_url":"https://api.github.com/users/timolehto/followers","following_url":"https://api.github.com/users/timolehto/following{/other_user}","gists_url":"https://api.github.com/users/timolehto/gists{/gist_id}","starred_url":"https://api.github.com/users/timolehto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timolehto/subscriptions","organizations_url":"https://api.github.com/users/timolehto/orgs","repos_url":"https://api.github.com/users/timolehto/repos","events_url":"https://api.github.com/users/timolehto/events{/privacy}","received_events_url":"https://api.github.com/users/timolehto/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-09-23T22:07:58Z","updated_at":"2017-09-24T08:05:12Z","closed_at":"2017-09-24T08:05:12Z","author_association":"NONE","body":"Is this expected, feels rather odd and strange to a rubyist? Tested with current latest docker image:\r\n\r\n```\r\ncrystal -v\r\nCrystal 0.23.1 [e2a1389] (2017-07-13) LLVM 3.8.1\r\n```\r\n\r\nMore complete demo:\r\n```\r\nrequire \"uri\"\r\nrequire \"http/client\"\r\nsample_url=\"https://example.com\"\r\nHTTP::Client.new(sample_url).port == 80\r\nHTTP::Client.new(URI.parse(sample_url)).port == 443\r\nHTTP::Client.get(sample_url) # => works\r\nHTTP::Client.new(sample_url).get(\"/\") # => error\r\n\r\nNo address found for https://example.com/:80 over TCP (Socket::Error)\r\n0x486f67: *CallStack::unwind:Array(Pointer(Void)) at ??\r\n0x486efa: *CallStack#initialize:Array(Pointer(Void)) at ??\r\n0x486eca: *CallStack::new:CallStack at ??\r\n0x483456: *raise<Socket::Error>:NoReturn at ??\r\n0x53a4c9: *TCPSocket#initialize<String, Int32, (Float64 | Nil), (Float64 | Nil)>:Nil at ??\r\n0x539ea4: *TCPSocket::new<String, Int32, (Float64 | Nil), (Float64 | Nil)>:TCPSocket at ??\r\n0x532c39: *HTTP::Client#socket:(OpenSSL::SSL::Socket+ | TCPSocket+) at ??\r\n0x532a4d: *HTTP::Client#exec_internal_single<HTTP::Request>:(HTTP::Client::Response | Nil) at ??\r\n0x52fd6c: *HTTP::Client#exec_internal<HTTP::Request>:HTTP::Client::Response at ??\r\n0x52fc52: *HTTP::Client#exec<HTTP::Request>:HTTP::Client::Response at ??\r\n0x52f996: *HTTP::Client#exec<String, String, Nil, Nil>:HTTP::Client::Response at ??\r\n0x533057: *HTTP::Client#get<String>:HTTP::Client::Response at ??\r\n0x482bce: *__icr_exec__:HTTP::Client::Response at ??\r\n0x470323: ??? at ??\r\n0x47fdd9: main at ??\r\n0x7f3b85504830: __libc_start_main at ??\r\n0x46fa29: _start at ??\r\n0x0: ??? at ??"},"comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments/331694325","html_url":"https://github.com/crystal-lang/crystal/issues/5027#issuecomment-331694325","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/5027","id":331694325,"user":{"login":"timolehto","id":491473,"avatar_url":"https://avatars3.githubusercontent.com/u/491473?v=4","gravatar_id":"","url":"https://api.github.com/users/timolehto","html_url":"https://github.com/timolehto","followers_url":"https://api.github.com/users/timolehto/followers","following_url":"https://api.github.com/users/timolehto/following{/other_user}","gists_url":"https://api.github.com/users/timolehto/gists{/gist_id}","starred_url":"https://api.github.com/users/timolehto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timolehto/subscriptions","organizations_url":"https://api.github.com/users/timolehto/orgs","repos_url":"https://api.github.com/users/timolehto/repos","events_url":"https://api.github.com/users/timolehto/events{/privacy}","received_events_url":"https://api.github.com/users/timolehto/received_events","type":"User","site_admin":false},"created_at":"2017-09-24T08:05:11Z","updated_at":"2017-09-24T08:05:11Z","author_association":"NONE","body":"Ok I see now how it's implemented. So the string variant does not expect nor can it handle a url, but plain host, no scheme, no path, query, port, nothing and it's the tls flag which dictates default port/protocol used. It feels kinda hairy and unintuitive to me, but I suppose it's as expected.\r\n\r\nSo I either do\r\n```\r\nrequire \"uri\"\r\nrequire \"http/client\"\r\nhost = \"example.com\"\r\nuri = \"https://example.com\"\r\nHTTP::Client.new(URI.parse(uri)).get(\"/\") #or\r\nHTTP::Client.new(host, tls: true).get(\"/\")"}}
{"actor":{"display_login":"timolehto"}}