{"action":"created","comment":{"url":"https://api.github.com/repos/nim-lang/Nim/pulls/comments/72686321","id":72686321,"diff_hunk":"@@ -399,6 +399,58 @@ proc request*(url: string, httpMethod: string, extraHeaders = \"\",\n   var hostUrl = if proxy == nil: r else: parseUri(url)\n   var headers = substr(httpMethod, len(\"http\"))\n   # TODO: Use generateHeaders further down once it supports proxies.\n+  \n+  var s = newSocket()\n+  if s == nil: raiseOSError(osLastError())\n+  var port = net.Port(80)\n+  if r.scheme == \"https\":\n+    when defined(ssl):\n+      sslContext.wrapSocket(s)\n+      port = net.Port(443)\n+    else:\n+      raise newException(HttpRequestError,\n+                \"SSL support is not available. Cannot connect over SSL.\")\n+  if r.port != \"\":\n+    port = net.Port(r.port.parseInt)\n+\n+\n+  # get the socket ready. If we are connecting through a proxy to SSL,\n+  # send the appropiate CONNECT header. If not, simply connect to the proper\n+  # host (which may still be the proxy, for normal HTTP)\n+  if proxy != nil and hostUrl.scheme == \"https\":\n+    when defined(ssl):\n+      var connectHeaders = \"CONNECT \"","path":"lib/pure/httpclient.nim","position":24,"original_position":24,"commit_id":"0ada2aedfafbe489f9f73b8b622804f6d1c0ed7a","original_commit_id":"0ada2aedfafbe489f9f73b8b622804f6d1c0ed7a","user":{"login":"RyanMarcus","id":3465514,"avatar_url":"https://avatars.githubusercontent.com/u/3465514?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanMarcus","html_url":"https://github.com/RyanMarcus","followers_url":"https://api.github.com/users/RyanMarcus/followers","following_url":"https://api.github.com/users/RyanMarcus/following{/other_user}","gists_url":"https://api.github.com/users/RyanMarcus/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanMarcus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanMarcus/subscriptions","organizations_url":"https://api.github.com/users/RyanMarcus/orgs","repos_url":"https://api.github.com/users/RyanMarcus/repos","events_url":"https://api.github.com/users/RyanMarcus/events{/privacy}","received_events_url":"https://api.github.com/users/RyanMarcus/received_events","type":"User","site_admin":false},"body":"To be clear, the client sends an HTTP `CONNECT` request to the proxy, which opens a socket to the server. Then the client sends a normal TLS handshake request to the proxy, which forwards it unmodified to the server.\r\n```\r\nclient --(HTTP CONNECT)--> proxy\r\nproxy --(raw socket)-->server\r\nclient --(TLS handshake)--> proxy\r\nproxy --(forward raw bytes of handshake)--> sever\r\nserver --(TLS response) --> proxy\r\nproxy --(raw TLS response)--> client\r\n```","created_at":"2016-07-28T19:27:39Z","updated_at":"2016-07-28T19:27:39Z","html_url":"https://github.com/nim-lang/Nim/pull/4523#discussion_r72686321","pull_request_url":"https://api.github.com/repos/nim-lang/Nim/pulls/4523","_links":{"self":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/comments/72686321"},"html":{"href":"https://github.com/nim-lang/Nim/pull/4523#discussion_r72686321"},"pull_request":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/4523"}}},"pull_request":{"url":"https://api.github.com/repos/nim-lang/Nim/pulls/4523","id":79104845,"html_url":"https://github.com/nim-lang/Nim/pull/4523","diff_url":"https://github.com/nim-lang/Nim/pull/4523.diff","patch_url":"https://github.com/nim-lang/Nim/pull/4523.patch","issue_url":"https://api.github.com/repos/nim-lang/Nim/issues/4523","number":4523,"state":"open","locked":false,"title":"Adds support for HTTPS over proxy","user":{"login":"RyanMarcus","id":3465514,"avatar_url":"https://avatars.githubusercontent.com/u/3465514?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanMarcus","html_url":"https://github.com/RyanMarcus","followers_url":"https://api.github.com/users/RyanMarcus/followers","following_url":"https://api.github.com/users/RyanMarcus/following{/other_user}","gists_url":"https://api.github.com/users/RyanMarcus/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanMarcus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanMarcus/subscriptions","organizations_url":"https://api.github.com/users/RyanMarcus/orgs","repos_url":"https://api.github.com/users/RyanMarcus/repos","events_url":"https://api.github.com/users/RyanMarcus/events{/privacy}","received_events_url":"https://api.github.com/users/RyanMarcus/received_events","type":"User","site_admin":false},"body":"This change refactors `request` slightly to sent an HTTP `CONNECT` to the HTTP proxy (when present) and when making an SSL request. It's a bit of hack, as clearly the procedure for socket construction should be moved out of request. There's already a `TODO` marker to change how the headers are constructed as well. But it works!\r\n\r\nI would add a test, but it appears the tests are not ran with `-d:ssl`, so I'm unsure how to do this. I'm also a little confused why -d:ssl isn't a default option, as SSL support seems pretty standard these days. I imagine it has something to do with linking to OpenSSL?\r\n\r\nThis fixes #4520 ","created_at":"2016-07-27T21:55:53Z","updated_at":"2016-07-28T19:27:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dd2005ffcdcacfeccfa25f0654de161f9d9f81b6","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/nim-lang/Nim/pulls/4523/commits","review_comments_url":"https://api.github.com/repos/nim-lang/Nim/pulls/4523/comments","review_comment_url":"https://api.github.com/repos/nim-lang/Nim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nim-lang/Nim/issues/4523/comments","statuses_url":"https://api.github.com/repos/nim-lang/Nim/statuses/0ada2aedfafbe489f9f73b8b622804f6d1c0ed7a","head":{"label":"RyanMarcus:devel","ref":"devel","sha":"0ada2aedfafbe489f9f73b8b622804f6d1c0ed7a","user":{"login":"RyanMarcus","id":3465514,"avatar_url":"https://avatars.githubusercontent.com/u/3465514?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanMarcus","html_url":"https://github.com/RyanMarcus","followers_url":"https://api.github.com/users/RyanMarcus/followers","following_url":"https://api.github.com/users/RyanMarcus/following{/other_user}","gists_url":"https://api.github.com/users/RyanMarcus/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanMarcus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanMarcus/subscriptions","organizations_url":"https://api.github.com/users/RyanMarcus/orgs","repos_url":"https://api.github.com/users/RyanMarcus/repos","events_url":"https://api.github.com/users/RyanMarcus/events{/privacy}","received_events_url":"https://api.github.com/users/RyanMarcus/received_events","type":"User","site_admin":false},"repo":{"id":64341264,"name":"Nim","full_name":"RyanMarcus/Nim","owner":{"login":"RyanMarcus","id":3465514,"avatar_url":"https://avatars.githubusercontent.com/u/3465514?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanMarcus","html_url":"https://github.com/RyanMarcus","followers_url":"https://api.github.com/users/RyanMarcus/followers","following_url":"https://api.github.com/users/RyanMarcus/following{/other_user}","gists_url":"https://api.github.com/users/RyanMarcus/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanMarcus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanMarcus/subscriptions","organizations_url":"https://api.github.com/users/RyanMarcus/orgs","repos_url":"https://api.github.com/users/RyanMarcus/repos","events_url":"https://api.github.com/users/RyanMarcus/events{/privacy}","received_events_url":"https://api.github.com/users/RyanMarcus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RyanMarcus/Nim","description":"Nim (formerly known as \"Nimrod\") is a compiled, garbage-collected systems programming language which has an excellent productivity/performance ratio. Nim's design focuses on efficiency, expressiveness, elegance (in the order of priority).","fork":true,"url":"https://api.github.com/repos/RyanMarcus/Nim","forks_url":"https://api.github.com/repos/RyanMarcus/Nim/forks","keys_url":"https://api.github.com/repos/RyanMarcus/Nim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RyanMarcus/Nim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RyanMarcus/Nim/teams","hooks_url":"https://api.github.com/repos/RyanMarcus/Nim/hooks","issue_events_url":"https://api.github.com/repos/RyanMarcus/Nim/issues/events{/number}","events_url":"https://api.github.com/repos/RyanMarcus/Nim/events","assignees_url":"https://api.github.com/repos/RyanMarcus/Nim/assignees{/user}","branches_url":"https://api.github.com/repos/RyanMarcus/Nim/branches{/branch}","tags_url":"https://api.github.com/repos/RyanMarcus/Nim/tags","blobs_url":"https://api.github.com/repos/RyanMarcus/Nim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RyanMarcus/Nim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RyanMarcus/Nim/git/refs{/sha}","trees_url":"https://api.github.com/repos/RyanMarcus/Nim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RyanMarcus/Nim/statuses/{sha}","languages_url":"https://api.github.com/repos/RyanMarcus/Nim/languages","stargazers_url":"https://api.github.com/repos/RyanMarcus/Nim/stargazers","contributors_url":"https://api.github.com/repos/RyanMarcus/Nim/contributors","subscribers_url":"https://api.github.com/repos/RyanMarcus/Nim/subscribers","subscription_url":"https://api.github.com/repos/RyanMarcus/Nim/subscription","commits_url":"https://api.github.com/repos/RyanMarcus/Nim/commits{/sha}","git_commits_url":"https://api.github.com/repos/RyanMarcus/Nim/git/commits{/sha}","comments_url":"https://api.github.com/repos/RyanMarcus/Nim/comments{/number}","issue_comment_url":"https://api.github.com/repos/RyanMarcus/Nim/issues/comments{/number}","contents_url":"https://api.github.com/repos/RyanMarcus/Nim/contents/{+path}","compare_url":"https://api.github.com/repos/RyanMarcus/Nim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RyanMarcus/Nim/merges","archive_url":"https://api.github.com/repos/RyanMarcus/Nim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RyanMarcus/Nim/downloads","issues_url":"https://api.github.com/repos/RyanMarcus/Nim/issues{/number}","pulls_url":"https://api.github.com/repos/RyanMarcus/Nim/pulls{/number}","milestones_url":"https://api.github.com/repos/RyanMarcus/Nim/milestones{/number}","notifications_url":"https://api.github.com/repos/RyanMarcus/Nim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RyanMarcus/Nim/labels{/name}","releases_url":"https://api.github.com/repos/RyanMarcus/Nim/releases{/id}","deployments_url":"https://api.github.com/repos/RyanMarcus/Nim/deployments","created_at":"2016-07-27T20:56:24Z","updated_at":"2016-07-27T20:56:29Z","pushed_at":"2016-07-27T21:26:13Z","git_url":"git://github.com/RyanMarcus/Nim.git","ssh_url":"git@github.com:RyanMarcus/Nim.git","clone_url":"https://github.com/RyanMarcus/Nim.git","svn_url":"https://github.com/RyanMarcus/Nim","homepage":"http://nim-lang.org/","size":42520,"stargazers_count":0,"watchers_count":0,"language":"Nimrod","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":"devel"}},"base":{"label":"nim-lang:devel","ref":"devel","sha":"27a40cd5a43175d273bf15af0ce0c269ea76a49b","user":{"login":"nim-lang","id":603863,"avatar_url":"https://avatars.githubusercontent.com/u/603863?v=3","gravatar_id":"","url":"https://api.github.com/users/nim-lang","html_url":"https://github.com/nim-lang","followers_url":"https://api.github.com/users/nim-lang/followers","following_url":"https://api.github.com/users/nim-lang/following{/other_user}","gists_url":"https://api.github.com/users/nim-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/nim-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nim-lang/subscriptions","organizations_url":"https://api.github.com/users/nim-lang/orgs","repos_url":"https://api.github.com/users/nim-lang/repos","events_url":"https://api.github.com/users/nim-lang/events{/privacy}","received_events_url":"https://api.github.com/users/nim-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":842037,"name":"Nim","full_name":"nim-lang/Nim","owner":{"login":"nim-lang","id":603863,"avatar_url":"https://avatars.githubusercontent.com/u/603863?v=3","gravatar_id":"","url":"https://api.github.com/users/nim-lang","html_url":"https://github.com/nim-lang","followers_url":"https://api.github.com/users/nim-lang/followers","following_url":"https://api.github.com/users/nim-lang/following{/other_user}","gists_url":"https://api.github.com/users/nim-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/nim-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nim-lang/subscriptions","organizations_url":"https://api.github.com/users/nim-lang/orgs","repos_url":"https://api.github.com/users/nim-lang/repos","events_url":"https://api.github.com/users/nim-lang/events{/privacy}","received_events_url":"https://api.github.com/users/nim-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nim-lang/Nim","description":"Nim (formerly known as \"Nimrod\") is a compiled, garbage-collected systems programming language which has an excellent productivity/performance ratio. Nim's design focuses on efficiency, expressiveness, elegance (in the order of priority).","fork":false,"url":"https://api.github.com/repos/nim-lang/Nim","forks_url":"https://api.github.com/repos/nim-lang/Nim/forks","keys_url":"https://api.github.com/repos/nim-lang/Nim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nim-lang/Nim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nim-lang/Nim/teams","hooks_url":"https://api.github.com/repos/nim-lang/Nim/hooks","issue_events_url":"https://api.github.com/repos/nim-lang/Nim/issues/events{/number}","events_url":"https://api.github.com/repos/nim-lang/Nim/events","assignees_url":"https://api.github.com/repos/nim-lang/Nim/assignees{/user}","branches_url":"https://api.github.com/repos/nim-lang/Nim/branches{/branch}","tags_url":"https://api.github.com/repos/nim-lang/Nim/tags","blobs_url":"https://api.github.com/repos/nim-lang/Nim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nim-lang/Nim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nim-lang/Nim/git/refs{/sha}","trees_url":"https://api.github.com/repos/nim-lang/Nim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nim-lang/Nim/statuses/{sha}","languages_url":"https://api.github.com/repos/nim-lang/Nim/languages","stargazers_url":"https://api.github.com/repos/nim-lang/Nim/stargazers","contributors_url":"https://api.github.com/repos/nim-lang/Nim/contributors","subscribers_url":"https://api.github.com/repos/nim-lang/Nim/subscribers","subscription_url":"https://api.github.com/repos/nim-lang/Nim/subscription","commits_url":"https://api.github.com/repos/nim-lang/Nim/commits{/sha}","git_commits_url":"https://api.github.com/repos/nim-lang/Nim/git/commits{/sha}","comments_url":"https://api.github.com/repos/nim-lang/Nim/comments{/number}","issue_comment_url":"https://api.github.com/repos/nim-lang/Nim/issues/comments{/number}","contents_url":"https://api.github.com/repos/nim-lang/Nim/contents/{+path}","compare_url":"https://api.github.com/repos/nim-lang/Nim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nim-lang/Nim/merges","archive_url":"https://api.github.com/repos/nim-lang/Nim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nim-lang/Nim/downloads","issues_url":"https://api.github.com/repos/nim-lang/Nim/issues{/number}","pulls_url":"https://api.github.com/repos/nim-lang/Nim/pulls{/number}","milestones_url":"https://api.github.com/repos/nim-lang/Nim/milestones{/number}","notifications_url":"https://api.github.com/repos/nim-lang/Nim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nim-lang/Nim/labels{/name}","releases_url":"https://api.github.com/repos/nim-lang/Nim/releases{/id}","deployments_url":"https://api.github.com/repos/nim-lang/Nim/deployments","created_at":"2010-08-16T20:38:58Z","updated_at":"2016-07-28T06:40:35Z","pushed_at":"2016-07-28T18:54:58Z","git_url":"git://github.com/nim-lang/Nim.git","ssh_url":"git@github.com:nim-lang/Nim.git","clone_url":"https://github.com/nim-lang/Nim.git","svn_url":"https://github.com/nim-lang/Nim","homepage":"http://nim-lang.org/","size":353669,"stargazers_count":2984,"watchers_count":2984,"language":"Nimrod","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":412,"mirror_url":null,"open_issues_count":776,"forks":412,"open_issues":776,"watchers":2984,"default_branch":"devel"}},"_links":{"self":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/4523"},"html":{"href":"https://github.com/nim-lang/Nim/pull/4523"},"issue":{"href":"https://api.github.com/repos/nim-lang/Nim/issues/4523"},"comments":{"href":"https://api.github.com/repos/nim-lang/Nim/issues/4523/comments"},"review_comments":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/4523/comments"},"review_comment":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nim-lang/Nim/pulls/4523/commits"},"statuses":{"href":"https://api.github.com/repos/nim-lang/Nim/statuses/0ada2aedfafbe489f9f73b8b622804f6d1c0ed7a"}}}}
{"actor":{"display_login":"RyanMarcus"}}