{"action":"created","comment":{"url":"https://api.github.com/repos/elixir-lang/elixir/pulls/comments/45666658","id":45666658,"diff_hunk":"@@ -393,12 +391,54 @@ defmodule Mix.Utils do\n     URI.parse(path).scheme in [\"http\", \"https\"]\n   end\n \n-  defp proxy(proxy_scheme, proxy) do\n-    uri  = URI.parse(proxy)\n+  def proxy_config(url) do\n+    {http_proxy, https_proxy} = proxy_env\n+\n+    proxy_auth(URI.parse(url), http_proxy, https_proxy)\n+  end\n+\n+  defp proxy_env do\n+    http_proxy  = System.get_env(\"HTTP_PROXY\")  || System.get_env(\"http_proxy\")\n+    https_proxy = System.get_env(\"HTTPS_PROXY\") || System.get_env(\"https_proxy\")\n+\n+    {proxy_setup(:http, http_proxy), proxy_setup(:https, https_proxy)}\n+  end\n+\n+  defp proxy_setup(scheme, proxy) do\n+    uri = URI.parse(proxy || \"\")\n \n     if uri.host && uri.port do\n       host = String.to_char_list(uri.host)\n-      :httpc.set_options([{proxy_scheme, {{host, uri.port}, []}}], :mix)\n+      :httpc.set_options([{proxy_scheme(scheme), {{host, uri.port}, []}}], :mix)\n     end\n+\n+    uri\n+  end\n+\n+  defp proxy_scheme(scheme) do\n+    case scheme do\n+      :http  -> :proxy\n+      :https -> :https_proxy\n+    end\n+  end\n+\n+  defp proxy_auth(%URI{scheme: \"http\"}, http_proxy, _https_proxy),\n+    do: proxy_auth(http_proxy)\n+  defp proxy_auth(%URI{scheme: \"https\"}, _http_proxy, https_proxy),\n+    do: proxy_auth(https_proxy)\n+\n+  defp proxy_auth(nil),\n+    do: []\n+  defp proxy_auth(%URI{userinfo: nil}),\n+    do: []\n+  defp proxy_auth(%URI{userinfo: auth}) do\n+    [user, pass] = case auth |> String.split(\":\") do","path":"lib/mix/lib/mix/utils.ex","position":71,"original_position":71,"commit_id":"e56890150d8d11d00079730f38b8e95b7c3defd4","original_commit_id":"e56890150d8d11d00079730f38b8e95b7c3defd4","user":{"login":"ericmj","id":316890,"avatar_url":"https://avatars.githubusercontent.com/u/316890?v=3","gravatar_id":"","url":"https://api.github.com/users/ericmj","html_url":"https://github.com/ericmj","followers_url":"https://api.github.com/users/ericmj/followers","following_url":"https://api.github.com/users/ericmj/following{/other_user}","gists_url":"https://api.github.com/users/ericmj/gists{/gist_id}","starred_url":"https://api.github.com/users/ericmj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericmj/subscriptions","organizations_url":"https://api.github.com/users/ericmj/orgs","repos_url":"https://api.github.com/users/ericmj/repos","events_url":"https://api.github.com/users/ericmj/events{/privacy}","received_events_url":"https://api.github.com/users/ericmj/received_events","type":"User","site_admin":false},"body":"Don't pipe single arguments like this. Write `String.split(auth, \":\")` instead, it is clearer.","created_at":"2015-11-23T21:56:12Z","updated_at":"2015-11-23T21:56:12Z","html_url":"https://github.com/elixir-lang/elixir/pull/3945#discussion_r45666658","pull_request_url":"https://api.github.com/repos/elixir-lang/elixir/pulls/3945","_links":{"self":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/comments/45666658"},"html":{"href":"https://github.com/elixir-lang/elixir/pull/3945#discussion_r45666658"},"pull_request":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/3945"}}},"pull_request":{"url":"https://api.github.com/repos/elixir-lang/elixir/pulls/3945","id":50034405,"html_url":"https://github.com/elixir-lang/elixir/pull/3945","diff_url":"https://github.com/elixir-lang/elixir/pull/3945.diff","patch_url":"https://github.com/elixir-lang/elixir/pull/3945.patch","issue_url":"https://api.github.com/repos/elixir-lang/elixir/issues/3945","number":3945,"state":"open","locked":false,"title":"Support for proxy auth with mix calls to httpc","user":{"login":"lbarratt","id":635764,"avatar_url":"https://avatars.githubusercontent.com/u/635764?v=3","gravatar_id":"","url":"https://api.github.com/users/lbarratt","html_url":"https://github.com/lbarratt","followers_url":"https://api.github.com/users/lbarratt/followers","following_url":"https://api.github.com/users/lbarratt/following{/other_user}","gists_url":"https://api.github.com/users/lbarratt/gists{/gist_id}","starred_url":"https://api.github.com/users/lbarratt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbarratt/subscriptions","organizations_url":"https://api.github.com/users/lbarratt/orgs","repos_url":"https://api.github.com/users/lbarratt/repos","events_url":"https://api.github.com/users/lbarratt/events{/privacy}","received_events_url":"https://api.github.com/users/lbarratt/received_events","type":"User","site_admin":false},"body":"This PR ensures that calls to `:httpc.request` using the `:mix` profile supply proxy authentication if they can be read from environment variables.\r\n\r\nMy use case is deploying elixir apps to an internal deployment of Cloud Foundry behind a firewall, limiting external connections to proxies. Hopefully others will find this useful!","created_at":"2015-11-07T11:46:28Z","updated_at":"2015-11-23T21:56:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c21dcb56ece1d9028dc05a9121f0f03d4c1bce0c","assignee":{"login":"ericmj","id":316890,"avatar_url":"https://avatars.githubusercontent.com/u/316890?v=3","gravatar_id":"","url":"https://api.github.com/users/ericmj","html_url":"https://github.com/ericmj","followers_url":"https://api.github.com/users/ericmj/followers","following_url":"https://api.github.com/users/ericmj/following{/other_user}","gists_url":"https://api.github.com/users/ericmj/gists{/gist_id}","starred_url":"https://api.github.com/users/ericmj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ericmj/subscriptions","organizations_url":"https://api.github.com/users/ericmj/orgs","repos_url":"https://api.github.com/users/ericmj/repos","events_url":"https://api.github.com/users/ericmj/events{/privacy}","received_events_url":"https://api.github.com/users/ericmj/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/elixir-lang/elixir/milestones/16","html_url":"https://github.com/elixir-lang/elixir/milestones/v1.2.0","labels_url":"https://api.github.com/repos/elixir-lang/elixir/milestones/16/labels","id":1248131,"number":16,"title":"v1.2.0","description":"","creator":{"login":"josevalim","id":9582,"avatar_url":"https://avatars.githubusercontent.com/u/9582?v=3","gravatar_id":"","url":"https://api.github.com/users/josevalim","html_url":"https://github.com/josevalim","followers_url":"https://api.github.com/users/josevalim/followers","following_url":"https://api.github.com/users/josevalim/following{/other_user}","gists_url":"https://api.github.com/users/josevalim/gists{/gist_id}","starred_url":"https://api.github.com/users/josevalim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josevalim/subscriptions","organizations_url":"https://api.github.com/users/josevalim/orgs","repos_url":"https://api.github.com/users/josevalim/repos","events_url":"https://api.github.com/users/josevalim/events{/privacy}","received_events_url":"https://api.github.com/users/josevalim/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":21,"state":"open","created_at":"2015-08-10T12:59:23Z","updated_at":"2015-11-23T13:00:16Z","due_on":"2015-12-20T23:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/elixir-lang/elixir/pulls/3945/commits","review_comments_url":"https://api.github.com/repos/elixir-lang/elixir/pulls/3945/comments","review_comment_url":"https://api.github.com/repos/elixir-lang/elixir/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elixir-lang/elixir/issues/3945/comments","statuses_url":"https://api.github.com/repos/elixir-lang/elixir/statuses/e56890150d8d11d00079730f38b8e95b7c3defd4","head":{"label":"lbarratt:feature/proxy-auth","ref":"feature/proxy-auth","sha":"e56890150d8d11d00079730f38b8e95b7c3defd4","user":{"login":"lbarratt","id":635764,"avatar_url":"https://avatars.githubusercontent.com/u/635764?v=3","gravatar_id":"","url":"https://api.github.com/users/lbarratt","html_url":"https://github.com/lbarratt","followers_url":"https://api.github.com/users/lbarratt/followers","following_url":"https://api.github.com/users/lbarratt/following{/other_user}","gists_url":"https://api.github.com/users/lbarratt/gists{/gist_id}","starred_url":"https://api.github.com/users/lbarratt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbarratt/subscriptions","organizations_url":"https://api.github.com/users/lbarratt/orgs","repos_url":"https://api.github.com/users/lbarratt/repos","events_url":"https://api.github.com/users/lbarratt/events{/privacy}","received_events_url":"https://api.github.com/users/lbarratt/received_events","type":"User","site_admin":false},"repo":{"id":44342900,"name":"elixir","full_name":"lbarratt/elixir","owner":{"login":"lbarratt","id":635764,"avatar_url":"https://avatars.githubusercontent.com/u/635764?v=3","gravatar_id":"","url":"https://api.github.com/users/lbarratt","html_url":"https://github.com/lbarratt","followers_url":"https://api.github.com/users/lbarratt/followers","following_url":"https://api.github.com/users/lbarratt/following{/other_user}","gists_url":"https://api.github.com/users/lbarratt/gists{/gist_id}","starred_url":"https://api.github.com/users/lbarratt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbarratt/subscriptions","organizations_url":"https://api.github.com/users/lbarratt/orgs","repos_url":"https://api.github.com/users/lbarratt/repos","events_url":"https://api.github.com/users/lbarratt/events{/privacy}","received_events_url":"https://api.github.com/users/lbarratt/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lbarratt/elixir","description":"Elixir is a dynamic, functional language designed for building scalable and maintainable applications","fork":true,"url":"https://api.github.com/repos/lbarratt/elixir","forks_url":"https://api.github.com/repos/lbarratt/elixir/forks","keys_url":"https://api.github.com/repos/lbarratt/elixir/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lbarratt/elixir/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lbarratt/elixir/teams","hooks_url":"https://api.github.com/repos/lbarratt/elixir/hooks","issue_events_url":"https://api.github.com/repos/lbarratt/elixir/issues/events{/number}","events_url":"https://api.github.com/repos/lbarratt/elixir/events","assignees_url":"https://api.github.com/repos/lbarratt/elixir/assignees{/user}","branches_url":"https://api.github.com/repos/lbarratt/elixir/branches{/branch}","tags_url":"https://api.github.com/repos/lbarratt/elixir/tags","blobs_url":"https://api.github.com/repos/lbarratt/elixir/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lbarratt/elixir/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lbarratt/elixir/git/refs{/sha}","trees_url":"https://api.github.com/repos/lbarratt/elixir/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lbarratt/elixir/statuses/{sha}","languages_url":"https://api.github.com/repos/lbarratt/elixir/languages","stargazers_url":"https://api.github.com/repos/lbarratt/elixir/stargazers","contributors_url":"https://api.github.com/repos/lbarratt/elixir/contributors","subscribers_url":"https://api.github.com/repos/lbarratt/elixir/subscribers","subscription_url":"https://api.github.com/repos/lbarratt/elixir/subscription","commits_url":"https://api.github.com/repos/lbarratt/elixir/commits{/sha}","git_commits_url":"https://api.github.com/repos/lbarratt/elixir/git/commits{/sha}","comments_url":"https://api.github.com/repos/lbarratt/elixir/comments{/number}","issue_comment_url":"https://api.github.com/repos/lbarratt/elixir/issues/comments{/number}","contents_url":"https://api.github.com/repos/lbarratt/elixir/contents/{+path}","compare_url":"https://api.github.com/repos/lbarratt/elixir/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lbarratt/elixir/merges","archive_url":"https://api.github.com/repos/lbarratt/elixir/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lbarratt/elixir/downloads","issues_url":"https://api.github.com/repos/lbarratt/elixir/issues{/number}","pulls_url":"https://api.github.com/repos/lbarratt/elixir/pulls{/number}","milestones_url":"https://api.github.com/repos/lbarratt/elixir/milestones{/number}","notifications_url":"https://api.github.com/repos/lbarratt/elixir/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lbarratt/elixir/labels{/name}","releases_url":"https://api.github.com/repos/lbarratt/elixir/releases{/id}","created_at":"2015-10-15T20:15:26Z","updated_at":"2015-10-15T20:15:32Z","pushed_at":"2015-11-07T11:31:55Z","git_url":"git://github.com/lbarratt/elixir.git","ssh_url":"git@github.com:lbarratt/elixir.git","clone_url":"https://github.com/lbarratt/elixir.git","svn_url":"https://github.com/lbarratt/elixir","homepage":"http://elixir-lang.org/","size":32083,"stargazers_count":0,"watchers_count":0,"language":"Elixir","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elixir-lang:master","ref":"master","sha":"cdb163e63433c5adb97f6d7f8783f304986a05be","user":{"login":"elixir-lang","id":1481354,"avatar_url":"https://avatars.githubusercontent.com/u/1481354?v=3","gravatar_id":"","url":"https://api.github.com/users/elixir-lang","html_url":"https://github.com/elixir-lang","followers_url":"https://api.github.com/users/elixir-lang/followers","following_url":"https://api.github.com/users/elixir-lang/following{/other_user}","gists_url":"https://api.github.com/users/elixir-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/elixir-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elixir-lang/subscriptions","organizations_url":"https://api.github.com/users/elixir-lang/orgs","repos_url":"https://api.github.com/users/elixir-lang/repos","events_url":"https://api.github.com/users/elixir-lang/events{/privacy}","received_events_url":"https://api.github.com/users/elixir-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":1234714,"name":"elixir","full_name":"elixir-lang/elixir","owner":{"login":"elixir-lang","id":1481354,"avatar_url":"https://avatars.githubusercontent.com/u/1481354?v=3","gravatar_id":"","url":"https://api.github.com/users/elixir-lang","html_url":"https://github.com/elixir-lang","followers_url":"https://api.github.com/users/elixir-lang/followers","following_url":"https://api.github.com/users/elixir-lang/following{/other_user}","gists_url":"https://api.github.com/users/elixir-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/elixir-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elixir-lang/subscriptions","organizations_url":"https://api.github.com/users/elixir-lang/orgs","repos_url":"https://api.github.com/users/elixir-lang/repos","events_url":"https://api.github.com/users/elixir-lang/events{/privacy}","received_events_url":"https://api.github.com/users/elixir-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elixir-lang/elixir","description":"Elixir is a dynamic, functional language designed for building scalable and maintainable applications","fork":false,"url":"https://api.github.com/repos/elixir-lang/elixir","forks_url":"https://api.github.com/repos/elixir-lang/elixir/forks","keys_url":"https://api.github.com/repos/elixir-lang/elixir/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elixir-lang/elixir/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elixir-lang/elixir/teams","hooks_url":"https://api.github.com/repos/elixir-lang/elixir/hooks","issue_events_url":"https://api.github.com/repos/elixir-lang/elixir/issues/events{/number}","events_url":"https://api.github.com/repos/elixir-lang/elixir/events","assignees_url":"https://api.github.com/repos/elixir-lang/elixir/assignees{/user}","branches_url":"https://api.github.com/repos/elixir-lang/elixir/branches{/branch}","tags_url":"https://api.github.com/repos/elixir-lang/elixir/tags","blobs_url":"https://api.github.com/repos/elixir-lang/elixir/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elixir-lang/elixir/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elixir-lang/elixir/git/refs{/sha}","trees_url":"https://api.github.com/repos/elixir-lang/elixir/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elixir-lang/elixir/statuses/{sha}","languages_url":"https://api.github.com/repos/elixir-lang/elixir/languages","stargazers_url":"https://api.github.com/repos/elixir-lang/elixir/stargazers","contributors_url":"https://api.github.com/repos/elixir-lang/elixir/contributors","subscribers_url":"https://api.github.com/repos/elixir-lang/elixir/subscribers","subscription_url":"https://api.github.com/repos/elixir-lang/elixir/subscription","commits_url":"https://api.github.com/repos/elixir-lang/elixir/commits{/sha}","git_commits_url":"https://api.github.com/repos/elixir-lang/elixir/git/commits{/sha}","comments_url":"https://api.github.com/repos/elixir-lang/elixir/comments{/number}","issue_comment_url":"https://api.github.com/repos/elixir-lang/elixir/issues/comments{/number}","contents_url":"https://api.github.com/repos/elixir-lang/elixir/contents/{+path}","compare_url":"https://api.github.com/repos/elixir-lang/elixir/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elixir-lang/elixir/merges","archive_url":"https://api.github.com/repos/elixir-lang/elixir/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elixir-lang/elixir/downloads","issues_url":"https://api.github.com/repos/elixir-lang/elixir/issues{/number}","pulls_url":"https://api.github.com/repos/elixir-lang/elixir/pulls{/number}","milestones_url":"https://api.github.com/repos/elixir-lang/elixir/milestones{/number}","notifications_url":"https://api.github.com/repos/elixir-lang/elixir/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elixir-lang/elixir/labels{/name}","releases_url":"https://api.github.com/repos/elixir-lang/elixir/releases{/id}","created_at":"2011-01-09T08:43:57Z","updated_at":"2015-11-23T21:04:58Z","pushed_at":"2015-11-23T21:48:20Z","git_url":"git://github.com/elixir-lang/elixir.git","ssh_url":"git@github.com:elixir-lang/elixir.git","clone_url":"https://github.com/elixir-lang/elixir.git","svn_url":"https://github.com/elixir-lang/elixir","homepage":"http://elixir-lang.org/","size":40163,"stargazers_count":5396,"watchers_count":5396,"language":"Elixir","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":750,"mirror_url":null,"open_issues_count":36,"forks":750,"open_issues":36,"watchers":5396,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/3945"},"html":{"href":"https://github.com/elixir-lang/elixir/pull/3945"},"issue":{"href":"https://api.github.com/repos/elixir-lang/elixir/issues/3945"},"comments":{"href":"https://api.github.com/repos/elixir-lang/elixir/issues/3945/comments"},"review_comments":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/3945/comments"},"review_comment":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elixir-lang/elixir/pulls/3945/commits"},"statuses":{"href":"https://api.github.com/repos/elixir-lang/elixir/statuses/e56890150d8d11d00079730f38b8e95b7c3defd4"}}}}