{"action":"created","comment":{"url":"https://api.github.com/repos/flynn/flynn/pulls/comments/24065937","id":24065937,"diff_hunk":"@@ -128,22 +128,32 @@ func (p *ReverseProxy) serveUpgrade(rw http.ResponseWriter, req *http.Request) {\n \t}\n \tdefer uconn.Close()\n \n-\tp.writeResponse(rw, res)\n-\tres.Body.Close()\n+\tdconn, bufrw, err := rw.(http.Hijacker).Hijack()\n+\tif err != nil {\n+\t\tp.logf(\"router: hijack failed: %v\", err)\n+\t\trw.WriteHeader(http.StatusServiceUnavailable)\n+\t\trw.Write(serviceUnavailable)\n+\t\treturn\n+\t}\n+\tdefer dconn.Close()\n \n+\tprepareResponseHeaders(res)\n \tif res.StatusCode != 101 {\n+\t\tres.Close = true\n+\t}\n+\tif err := res.Write(dconn); err != nil {\n \t\treturn\n \t}\n+\tres.Body.Close()","path":"router/proxy/reverseproxy.go","position":22,"original_position":22,"commit_id":"195210ff19fc2c9a535bfe015f75b97d2ab7f549","original_commit_id":"195210ff19fc2c9a535bfe015f75b97d2ab7f549","user":{"login":"bgentry","id":114033,"avatar_url":"https://avatars.githubusercontent.com/u/114033?v=3","gravatar_id":"","url":"https://api.github.com/users/bgentry","html_url":"https://github.com/bgentry","followers_url":"https://api.github.com/users/bgentry/followers","following_url":"https://api.github.com/users/bgentry/following{/other_user}","gists_url":"https://api.github.com/users/bgentry/gists{/gist_id}","starred_url":"https://api.github.com/users/bgentry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgentry/subscriptions","organizations_url":"https://api.github.com/users/bgentry/orgs","repos_url":"https://api.github.com/users/bgentry/repos","events_url":"https://api.github.com/users/bgentry/events{/privacy}","received_events_url":"https://api.github.com/users/bgentry/received_events","type":"User","site_admin":false},"body":"yep, missed that, good call :v:","created_at":"2015-02-04T07:00:27Z","updated_at":"2015-02-04T07:00:27Z","html_url":"https://github.com/flynn/flynn/pull/950#discussion_r24065937","pull_request_url":"https://api.github.com/repos/flynn/flynn/pulls/950","_links":{"self":{"href":"https://api.github.com/repos/flynn/flynn/pulls/comments/24065937"},"html":{"href":"https://github.com/flynn/flynn/pull/950#discussion_r24065937"},"pull_request":{"href":"https://api.github.com/repos/flynn/flynn/pulls/950"}}},"pull_request":{"url":"https://api.github.com/repos/flynn/flynn/pulls/950","id":28602731,"html_url":"https://github.com/flynn/flynn/pull/950","diff_url":"https://github.com/flynn/flynn/pull/950.diff","patch_url":"https://github.com/flynn/flynn/pull/950.patch","issue_url":"https://api.github.com/repos/flynn/flynn/issues/950","number":950,"state":"open","locked":false,"title":"router: hijack conn before writing response","user":{"login":"bgentry","id":114033,"avatar_url":"https://avatars.githubusercontent.com/u/114033?v=3","gravatar_id":"","url":"https://api.github.com/users/bgentry","html_url":"https://github.com/bgentry","followers_url":"https://api.github.com/users/bgentry/followers","following_url":"https://api.github.com/users/bgentry/following{/other_user}","gists_url":"https://api.github.com/users/bgentry/gists{/gist_id}","starred_url":"https://api.github.com/users/bgentry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgentry/subscriptions","organizations_url":"https://api.github.com/users/bgentry/orgs","repos_url":"https://api.github.com/users/bgentry/repos","events_url":"https://api.github.com/users/bgentry/events{/privacy}","received_events_url":"https://api.github.com/users/bgentry/received_events","type":"User","site_admin":false},"body":"If we don't attempt to hijack the client conn before we write a response\r\nto it, the hijack may fail, but we will have no way of telling the\r\nclient or backend about that.\r\n\r\nCouldn't think of a way to write a test for this. Any ideas?\r\n\r\nRegardless, this should fix the issue we discussed towards the end of #926. /cc @benburkert ","created_at":"2015-02-04T00:20:54Z","updated_at":"2015-02-04T07:00:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"becee82edae7cfe398280f14c106c9922dd60dfd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/flynn/flynn/pulls/950/commits","review_comments_url":"https://api.github.com/repos/flynn/flynn/pulls/950/comments","review_comment_url":"https://api.github.com/repos/flynn/flynn/pulls/comments/{number}","comments_url":"https://api.github.com/repos/flynn/flynn/issues/950/comments","statuses_url":"https://api.github.com/repos/flynn/flynn/statuses/195210ff19fc2c9a535bfe015f75b97d2ab7f549","head":{"label":"bgentry:router-fix-upgrade-on-failed-hijack","ref":"router-fix-upgrade-on-failed-hijack","sha":"195210ff19fc2c9a535bfe015f75b97d2ab7f549","user":{"login":"bgentry","id":114033,"avatar_url":"https://avatars.githubusercontent.com/u/114033?v=3","gravatar_id":"","url":"https://api.github.com/users/bgentry","html_url":"https://github.com/bgentry","followers_url":"https://api.github.com/users/bgentry/followers","following_url":"https://api.github.com/users/bgentry/following{/other_user}","gists_url":"https://api.github.com/users/bgentry/gists{/gist_id}","starred_url":"https://api.github.com/users/bgentry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgentry/subscriptions","organizations_url":"https://api.github.com/users/bgentry/orgs","repos_url":"https://api.github.com/users/bgentry/repos","events_url":"https://api.github.com/users/bgentry/events{/privacy}","received_events_url":"https://api.github.com/users/bgentry/received_events","type":"User","site_admin":false},"repo":{"id":29484741,"name":"flynn","full_name":"bgentry/flynn","owner":{"login":"bgentry","id":114033,"avatar_url":"https://avatars.githubusercontent.com/u/114033?v=3","gravatar_id":"","url":"https://api.github.com/users/bgentry","html_url":"https://github.com/bgentry","followers_url":"https://api.github.com/users/bgentry/followers","following_url":"https://api.github.com/users/bgentry/following{/other_user}","gists_url":"https://api.github.com/users/bgentry/gists{/gist_id}","starred_url":"https://api.github.com/users/bgentry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgentry/subscriptions","organizations_url":"https://api.github.com/users/bgentry/orgs","repos_url":"https://api.github.com/users/bgentry/repos","events_url":"https://api.github.com/users/bgentry/events{/privacy}","received_events_url":"https://api.github.com/users/bgentry/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bgentry/flynn","description":"A next generation open source platform as a service (PaaS)","fork":true,"url":"https://api.github.com/repos/bgentry/flynn","forks_url":"https://api.github.com/repos/bgentry/flynn/forks","keys_url":"https://api.github.com/repos/bgentry/flynn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bgentry/flynn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bgentry/flynn/teams","hooks_url":"https://api.github.com/repos/bgentry/flynn/hooks","issue_events_url":"https://api.github.com/repos/bgentry/flynn/issues/events{/number}","events_url":"https://api.github.com/repos/bgentry/flynn/events","assignees_url":"https://api.github.com/repos/bgentry/flynn/assignees{/user}","branches_url":"https://api.github.com/repos/bgentry/flynn/branches{/branch}","tags_url":"https://api.github.com/repos/bgentry/flynn/tags","blobs_url":"https://api.github.com/repos/bgentry/flynn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bgentry/flynn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bgentry/flynn/git/refs{/sha}","trees_url":"https://api.github.com/repos/bgentry/flynn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bgentry/flynn/statuses/{sha}","languages_url":"https://api.github.com/repos/bgentry/flynn/languages","stargazers_url":"https://api.github.com/repos/bgentry/flynn/stargazers","contributors_url":"https://api.github.com/repos/bgentry/flynn/contributors","subscribers_url":"https://api.github.com/repos/bgentry/flynn/subscribers","subscription_url":"https://api.github.com/repos/bgentry/flynn/subscription","commits_url":"https://api.github.com/repos/bgentry/flynn/commits{/sha}","git_commits_url":"https://api.github.com/repos/bgentry/flynn/git/commits{/sha}","comments_url":"https://api.github.com/repos/bgentry/flynn/comments{/number}","issue_comment_url":"https://api.github.com/repos/bgentry/flynn/issues/comments/{number}","contents_url":"https://api.github.com/repos/bgentry/flynn/contents/{+path}","compare_url":"https://api.github.com/repos/bgentry/flynn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bgentry/flynn/merges","archive_url":"https://api.github.com/repos/bgentry/flynn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bgentry/flynn/downloads","issues_url":"https://api.github.com/repos/bgentry/flynn/issues{/number}","pulls_url":"https://api.github.com/repos/bgentry/flynn/pulls{/number}","milestones_url":"https://api.github.com/repos/bgentry/flynn/milestones{/number}","notifications_url":"https://api.github.com/repos/bgentry/flynn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bgentry/flynn/labels{/name}","releases_url":"https://api.github.com/repos/bgentry/flynn/releases{/id}","created_at":"2015-01-19T18:20:14Z","updated_at":"2015-01-29T18:42:10Z","pushed_at":"2015-02-04T00:19:30Z","git_url":"git://github.com/bgentry/flynn.git","ssh_url":"git@github.com:bgentry/flynn.git","clone_url":"https://github.com/bgentry/flynn.git","svn_url":"https://github.com/bgentry/flynn","homepage":"https://flynn.io","size":11602,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"flynn:master","ref":"master","sha":"a11e5d00b4c960331ee2870ed442a820e497ed31","user":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=3","gravatar_id":"","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"repo":{"id":11290232,"name":"flynn","full_name":"flynn/flynn","owner":{"login":"flynn","id":4973613,"avatar_url":"https://avatars.githubusercontent.com/u/4973613?v=3","gravatar_id":"","url":"https://api.github.com/users/flynn","html_url":"https://github.com/flynn","followers_url":"https://api.github.com/users/flynn/followers","following_url":"https://api.github.com/users/flynn/following{/other_user}","gists_url":"https://api.github.com/users/flynn/gists{/gist_id}","starred_url":"https://api.github.com/users/flynn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flynn/subscriptions","organizations_url":"https://api.github.com/users/flynn/orgs","repos_url":"https://api.github.com/users/flynn/repos","events_url":"https://api.github.com/users/flynn/events{/privacy}","received_events_url":"https://api.github.com/users/flynn/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/flynn/flynn","description":"A next generation open source platform as a service (PaaS)","fork":false,"url":"https://api.github.com/repos/flynn/flynn","forks_url":"https://api.github.com/repos/flynn/flynn/forks","keys_url":"https://api.github.com/repos/flynn/flynn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flynn/flynn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flynn/flynn/teams","hooks_url":"https://api.github.com/repos/flynn/flynn/hooks","issue_events_url":"https://api.github.com/repos/flynn/flynn/issues/events{/number}","events_url":"https://api.github.com/repos/flynn/flynn/events","assignees_url":"https://api.github.com/repos/flynn/flynn/assignees{/user}","branches_url":"https://api.github.com/repos/flynn/flynn/branches{/branch}","tags_url":"https://api.github.com/repos/flynn/flynn/tags","blobs_url":"https://api.github.com/repos/flynn/flynn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flynn/flynn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flynn/flynn/git/refs{/sha}","trees_url":"https://api.github.com/repos/flynn/flynn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flynn/flynn/statuses/{sha}","languages_url":"https://api.github.com/repos/flynn/flynn/languages","stargazers_url":"https://api.github.com/repos/flynn/flynn/stargazers","contributors_url":"https://api.github.com/repos/flynn/flynn/contributors","subscribers_url":"https://api.github.com/repos/flynn/flynn/subscribers","subscription_url":"https://api.github.com/repos/flynn/flynn/subscription","commits_url":"https://api.github.com/repos/flynn/flynn/commits{/sha}","git_commits_url":"https://api.github.com/repos/flynn/flynn/git/commits{/sha}","comments_url":"https://api.github.com/repos/flynn/flynn/comments{/number}","issue_comment_url":"https://api.github.com/repos/flynn/flynn/issues/comments/{number}","contents_url":"https://api.github.com/repos/flynn/flynn/contents/{+path}","compare_url":"https://api.github.com/repos/flynn/flynn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flynn/flynn/merges","archive_url":"https://api.github.com/repos/flynn/flynn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flynn/flynn/downloads","issues_url":"https://api.github.com/repos/flynn/flynn/issues{/number}","pulls_url":"https://api.github.com/repos/flynn/flynn/pulls{/number}","milestones_url":"https://api.github.com/repos/flynn/flynn/milestones{/number}","notifications_url":"https://api.github.com/repos/flynn/flynn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flynn/flynn/labels{/name}","releases_url":"https://api.github.com/repos/flynn/flynn/releases{/id}","created_at":"2013-07-09T18:22:06Z","updated_at":"2015-02-04T04:02:28Z","pushed_at":"2015-02-04T06:20:41Z","git_url":"git://github.com/flynn/flynn.git","ssh_url":"git@github.com:flynn/flynn.git","clone_url":"https://github.com/flynn/flynn.git","svn_url":"https://github.com/flynn/flynn","homepage":"https://flynn.io","size":36752,"stargazers_count":3215,"watchers_count":3215,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":204,"mirror_url":null,"open_issues_count":115,"forks":204,"open_issues":115,"watchers":3215,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/flynn/flynn/pulls/950"},"html":{"href":"https://github.com/flynn/flynn/pull/950"},"issue":{"href":"https://api.github.com/repos/flynn/flynn/issues/950"},"comments":{"href":"https://api.github.com/repos/flynn/flynn/issues/950/comments"},"review_comments":{"href":"https://api.github.com/repos/flynn/flynn/pulls/950/comments"},"review_comment":{"href":"https://api.github.com/repos/flynn/flynn/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/flynn/flynn/pulls/950/commits"},"statuses":{"href":"https://api.github.com/repos/flynn/flynn/statuses/195210ff19fc2c9a535bfe015f75b97d2ab7f549"}}}}