{"action":"created","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/3455","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3455/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3455/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3455/events","html_url":"https://github.com/crystal-lang/crystal/issues/3455","id":184571101,"number":3455,"title":"Allow HTTP::Client.new to accept a URL or URI","user":{"login":"iDev0urer","id":4535422,"avatar_url":"https://avatars.githubusercontent.com/u/4535422?v=3","gravatar_id":"","url":"https://api.github.com/users/iDev0urer","html_url":"https://github.com/iDev0urer","followers_url":"https://api.github.com/users/iDev0urer/followers","following_url":"https://api.github.com/users/iDev0urer/following{/other_user}","gists_url":"https://api.github.com/users/iDev0urer/gists{/gist_id}","starred_url":"https://api.github.com/users/iDev0urer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iDev0urer/subscriptions","organizations_url":"https://api.github.com/users/iDev0urer/orgs","repos_url":"https://api.github.com/users/iDev0urer/repos","events_url":"https://api.github.com/users/iDev0urer/events{/privacy}","received_events_url":"https://api.github.com/users/iDev0urer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-21T21:13:40Z","updated_at":"2016-10-22T03:36:28Z","closed_at":null,"body":"Instantiating a new HTTP::Client was confusing for me at first until I realized it wanted a URL instead of a URI. I think it would be nice if it could accept either.\r\n\r\nHere is an example of what I tried at first.\r\n```crystal\r\nrequire \"http/client\"\r\n\r\nclient = HTTP::Client.new \"http://www.google.com\"\r\nresponse = client.get \"/\" # => getaddrinfo: Name or service not known\r\nresponse.status_code\r\nresponse.body.lines.first\r\nclient.close\r\n```\r\n\r\nAnd then when I got rid of the `http://` it worked.\r\n```crystal\r\nrequire \"http/client\"\r\n\r\nclient = HTTP::Client.new \"www.google.com\"\r\nresponse = client.get \"/\"\r\nresponse.status_code      # => 200\r\nresponse.body.lines.first # => \"<!doctype html>\"\r\nclient.close\r\n```\r\n\r\nAt the very least this should be better documented, but I think that if methods such as `get` and `post` accept a url, then `initialize` should as well. Thoughts?"},"comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments/255504929","html_url":"https://github.com/crystal-lang/crystal/issues/3455#issuecomment-255504929","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/3455","id":255504929,"user":{"login":"iDev0urer","id":4535422,"avatar_url":"https://avatars.githubusercontent.com/u/4535422?v=3","gravatar_id":"","url":"https://api.github.com/users/iDev0urer","html_url":"https://github.com/iDev0urer","followers_url":"https://api.github.com/users/iDev0urer/followers","following_url":"https://api.github.com/users/iDev0urer/following{/other_user}","gists_url":"https://api.github.com/users/iDev0urer/gists{/gist_id}","starred_url":"https://api.github.com/users/iDev0urer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iDev0urer/subscriptions","organizations_url":"https://api.github.com/users/iDev0urer/orgs","repos_url":"https://api.github.com/users/iDev0urer/repos","events_url":"https://api.github.com/users/iDev0urer/events{/privacy}","received_events_url":"https://api.github.com/users/iDev0urer/received_events","type":"User","site_admin":false},"created_at":"2016-10-22T03:36:28Z","updated_at":"2016-10-22T03:36:28Z","body":"@RX14 You're right. I was just a little confused in the beginning I guess"}}
{"actor":{"display_login":"iDev0urer"}}