{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/4638","labels_url":"https://api.github.com/repos/nodejs/node/issues/4638/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/4638/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/4638/events","html_url":"https://github.com/nodejs/node/pull/4638","id":126097380,"number":4638,"title":"http: allow async createConnection()","user":{"login":"mscdex","id":54666,"avatar_url":"https://avatars.githubusercontent.com/u/54666?v=3","gravatar_id":"","url":"https://api.github.com/users/mscdex","html_url":"https://github.com/mscdex","followers_url":"https://api.github.com/users/mscdex/followers","following_url":"https://api.github.com/users/mscdex/following{/other_user}","gists_url":"https://api.github.com/users/mscdex/gists{/gist_id}","starred_url":"https://api.github.com/users/mscdex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mscdex/subscriptions","organizations_url":"https://api.github.com/users/mscdex/orgs","repos_url":"https://api.github.com/users/mscdex/repos","events_url":"https://api.github.com/users/mscdex/events{/privacy}","received_events_url":"https://api.github.com/users/mscdex/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodejs/node/labels/http","name":"http","color":"c7def8"},{"url":"https://api.github.com/repos/nodejs/node/labels/semver-minor","name":"semver-minor","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2016-01-12T04:49:53Z","updated_at":"2016-01-31T21:44:38Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/4638","html_url":"https://github.com/nodejs/node/pull/4638","diff_url":"https://github.com/nodejs/node/pull/4638.diff","patch_url":"https://github.com/nodejs/node/pull/4638.patch"},"body":"This commit adds support for async `createConnection()` implementations and is still backwards compatible with synchronous `createConnection()` implementations.\r\n\r\nThis commit also makes the http client more friendly with generic stream objects produced by `createConnection()` by checking `stream.writable` instead of `stream.destroyed` as the latter is currently a `net.Socket`-ism and not set by the core stream implementations.\r\n\r\nThe original use case behind this PR is that it allows the creation of a _minimal_, custom Http.Agent that allows you to make in-process http requests over ssh. The async-ness comes into play because the way ssh works is you have to ask the server to start a TCP connection first. You *could* return some sort of dummy socket object, but `ssh2` already provides a stream object when the server allows the TCP connection, so adding yet another object for every connection just makes things more complicated.\r\n\r\nNote: I wasn't quite sure how to handle the errors passed to the `oncreate()` callback. The same problem exists for the synchronous use. How do you signal to the http client/agent that no socket was able to be created without returning a dummy object that emits an error or something?"},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/177623057","html_url":"https://github.com/nodejs/node/pull/4638#issuecomment-177623057","issue_url":"https://api.github.com/repos/nodejs/node/issues/4638","id":177623057,"user":{"login":"mscdex","id":54666,"avatar_url":"https://avatars.githubusercontent.com/u/54666?v=3","gravatar_id":"","url":"https://api.github.com/users/mscdex","html_url":"https://github.com/mscdex","followers_url":"https://api.github.com/users/mscdex/followers","following_url":"https://api.github.com/users/mscdex/following{/other_user}","gists_url":"https://api.github.com/users/mscdex/gists{/gist_id}","starred_url":"https://api.github.com/users/mscdex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mscdex/subscriptions","organizations_url":"https://api.github.com/users/mscdex/orgs","repos_url":"https://api.github.com/users/mscdex/repos","events_url":"https://api.github.com/users/mscdex/events{/privacy}","received_events_url":"https://api.github.com/users/mscdex/received_events","type":"User","site_admin":false},"created_at":"2016-01-31T21:44:38Z","updated_at":"2016-01-31T21:44:38Z","body":"CI is green except for some unrelated test failures on pi1."}}