{"action":"created","comment":{"url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/comments/40883957","id":40883957,"diff_hunk":"@@ -343,14 +344,47 @@ func (c *Client) setRequestBody(req *http.Request, body io.ReadSeeker) error {\n \tif body == nil {\n \t\treturn nil\n \t}\n-\tif req.Body == nil {\n-\t\treq.Body = ioutil.NopCloser(body)\n-\t} else {\n-\t\t_, err := body.Seek(0, 0)\n-\t\tif err != nil {\n+\tif req.Body != nil {\n+\t\treq.Body.Close()\n+\t\tif _, err := body.Seek(0, 0); err != nil {\n \t\t\treturn errgo.Notef(err, \"cannot seek to start of request body\")\n \t\t}\n \t}\n+\t// Always replace the body with a new readStopper so that\n+\t// the old request cannot interfere with the new request's reader.\n+\treq.Body = &readStopper{\n+\t\tr: body,\n+\t}\n+\treturn nil\n+}\n+\n+var errClosed = errgo.New(\"reader has been closed\")","path":"httpbakery/client.go","position":31,"original_position":31,"commit_id":"50678de4fdcd869953152e20a01b2c31fa597855","original_commit_id":"50678de4fdcd869953152e20a01b2c31fa597855","user":{"login":"alesstimec","id":5555154,"avatar_url":"https://avatars.githubusercontent.com/u/5555154?v=3","gravatar_id":"","url":"https://api.github.com/users/alesstimec","html_url":"https://github.com/alesstimec","followers_url":"https://api.github.com/users/alesstimec/followers","following_url":"https://api.github.com/users/alesstimec/following{/other_user}","gists_url":"https://api.github.com/users/alesstimec/gists{/gist_id}","starred_url":"https://api.github.com/users/alesstimec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alesstimec/subscriptions","organizations_url":"https://api.github.com/users/alesstimec/orgs","repos_url":"https://api.github.com/users/alesstimec/repos","events_url":"https://api.github.com/users/alesstimec/events{/privacy}","received_events_url":"https://api.github.com/users/alesstimec/received_events","type":"User","site_admin":false},"body":"this error is only used in one place.. maybe we could return errgo.New(\"reader has been closed\") in L381","created_at":"2015-10-01T06:56:00Z","updated_at":"2015-10-01T06:56:00Z","html_url":"https://github.com/go-macaroon-bakery/macaroon-bakery/pull/73#discussion_r40883957","pull_request_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/73","_links":{"self":{"href":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/comments/40883957"},"html":{"href":"https://github.com/go-macaroon-bakery/macaroon-bakery/pull/73#discussion_r40883957"},"pull_request":{"href":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/73"}}},"pull_request":{"url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/73","id":46431221,"html_url":"https://github.com/go-macaroon-bakery/macaroon-bakery/pull/73","diff_url":"https://github.com/go-macaroon-bakery/macaroon-bakery/pull/73.diff","patch_url":"https://github.com/go-macaroon-bakery/macaroon-bakery/pull/73.patch","issue_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/issues/73","number":73,"state":"open","locked":false,"title":"httpbakery: work around go issue #12796","user":{"login":"rogpeppe","id":66491,"avatar_url":"https://avatars.githubusercontent.com/u/66491?v=3","gravatar_id":"","url":"https://api.github.com/users/rogpeppe","html_url":"https://github.com/rogpeppe","followers_url":"https://api.github.com/users/rogpeppe/followers","following_url":"https://api.github.com/users/rogpeppe/following{/other_user}","gists_url":"https://api.github.com/users/rogpeppe/gists{/gist_id}","starred_url":"https://api.github.com/users/rogpeppe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogpeppe/subscriptions","organizations_url":"https://api.github.com/users/rogpeppe/orgs","repos_url":"https://api.github.com/users/rogpeppe/repos","events_url":"https://api.github.com/users/rogpeppe/events{/privacy}","received_events_url":"https://api.github.com/users/rogpeppe/received_events","type":"User","site_admin":false},"body":"We ensure that the tardy reads made by http.Request.Do cannot harm\r\nour readers.\r\n","created_at":"2015-09-30T17:26:59Z","updated_at":"2015-10-01T06:56:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78e297dfef12295d066394cfe50385a4216acefc","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/73/commits","review_comments_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/73/comments","review_comment_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/comments{/number}","comments_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/issues/73/comments","statuses_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/statuses/50678de4fdcd869953152e20a01b2c31fa597855","head":{"label":"rogpeppe:046-fix-http-do-race","ref":"046-fix-http-do-race","sha":"50678de4fdcd869953152e20a01b2c31fa597855","user":{"login":"rogpeppe","id":66491,"avatar_url":"https://avatars.githubusercontent.com/u/66491?v=3","gravatar_id":"","url":"https://api.github.com/users/rogpeppe","html_url":"https://github.com/rogpeppe","followers_url":"https://api.github.com/users/rogpeppe/followers","following_url":"https://api.github.com/users/rogpeppe/following{/other_user}","gists_url":"https://api.github.com/users/rogpeppe/gists{/gist_id}","starred_url":"https://api.github.com/users/rogpeppe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogpeppe/subscriptions","organizations_url":"https://api.github.com/users/rogpeppe/orgs","repos_url":"https://api.github.com/users/rogpeppe/repos","events_url":"https://api.github.com/users/rogpeppe/events{/privacy}","received_events_url":"https://api.github.com/users/rogpeppe/received_events","type":"User","site_admin":false},"repo":{"id":26593657,"name":"macaroon-bakery","full_name":"rogpeppe/macaroon-bakery","owner":{"login":"rogpeppe","id":66491,"avatar_url":"https://avatars.githubusercontent.com/u/66491?v=3","gravatar_id":"","url":"https://api.github.com/users/rogpeppe","html_url":"https://github.com/rogpeppe","followers_url":"https://api.github.com/users/rogpeppe/followers","following_url":"https://api.github.com/users/rogpeppe/following{/other_user}","gists_url":"https://api.github.com/users/rogpeppe/gists{/gist_id}","starred_url":"https://api.github.com/users/rogpeppe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogpeppe/subscriptions","organizations_url":"https://api.github.com/users/rogpeppe/orgs","repos_url":"https://api.github.com/users/rogpeppe/repos","events_url":"https://api.github.com/users/rogpeppe/events{/privacy}","received_events_url":"https://api.github.com/users/rogpeppe/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rogpeppe/macaroon-bakery","description":"We bake 'em sweet, we bake 'em nice","fork":true,"url":"https://api.github.com/repos/rogpeppe/macaroon-bakery","forks_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/forks","keys_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/teams","hooks_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/hooks","issue_events_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/issues/events{/number}","events_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/events","assignees_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/assignees{/user}","branches_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/branches{/branch}","tags_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/tags","blobs_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/git/refs{/sha}","trees_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/statuses/{sha}","languages_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/languages","stargazers_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/stargazers","contributors_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/contributors","subscribers_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/subscribers","subscription_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/subscription","commits_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/commits{/sha}","git_commits_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/git/commits{/sha}","comments_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/comments{/number}","issue_comment_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/issues/comments{/number}","contents_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/contents/{+path}","compare_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/merges","archive_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/downloads","issues_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/issues{/number}","pulls_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/pulls{/number}","milestones_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/milestones{/number}","notifications_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/labels{/name}","releases_url":"https://api.github.com/repos/rogpeppe/macaroon-bakery/releases{/id}","created_at":"2014-11-13T15:18:37Z","updated_at":"2014-12-11T03:12:38Z","pushed_at":"2015-09-30T17:26:14Z","git_url":"git://github.com/rogpeppe/macaroon-bakery.git","ssh_url":"git@github.com:rogpeppe/macaroon-bakery.git","clone_url":"https://github.com/rogpeppe/macaroon-bakery.git","svn_url":"https://github.com/rogpeppe/macaroon-bakery","homepage":null,"size":761,"stargazers_count":1,"watchers_count":1,"language":"Go","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":1,"default_branch":"v0"}},"base":{"label":"go-macaroon-bakery:v1","ref":"v1","sha":"d3b2b51f823042d4b13d0f6a892e75a6384121b7","user":{"login":"go-macaroon-bakery","id":9721471,"avatar_url":"https://avatars.githubusercontent.com/u/9721471?v=3","gravatar_id":"","url":"https://api.github.com/users/go-macaroon-bakery","html_url":"https://github.com/go-macaroon-bakery","followers_url":"https://api.github.com/users/go-macaroon-bakery/followers","following_url":"https://api.github.com/users/go-macaroon-bakery/following{/other_user}","gists_url":"https://api.github.com/users/go-macaroon-bakery/gists{/gist_id}","starred_url":"https://api.github.com/users/go-macaroon-bakery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/go-macaroon-bakery/subscriptions","organizations_url":"https://api.github.com/users/go-macaroon-bakery/orgs","repos_url":"https://api.github.com/users/go-macaroon-bakery/repos","events_url":"https://api.github.com/users/go-macaroon-bakery/events{/privacy}","received_events_url":"https://api.github.com/users/go-macaroon-bakery/received_events","type":"Organization","site_admin":false},"repo":{"id":26593206,"name":"macaroon-bakery","full_name":"go-macaroon-bakery/macaroon-bakery","owner":{"login":"go-macaroon-bakery","id":9721471,"avatar_url":"https://avatars.githubusercontent.com/u/9721471?v=3","gravatar_id":"","url":"https://api.github.com/users/go-macaroon-bakery","html_url":"https://github.com/go-macaroon-bakery","followers_url":"https://api.github.com/users/go-macaroon-bakery/followers","following_url":"https://api.github.com/users/go-macaroon-bakery/following{/other_user}","gists_url":"https://api.github.com/users/go-macaroon-bakery/gists{/gist_id}","starred_url":"https://api.github.com/users/go-macaroon-bakery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/go-macaroon-bakery/subscriptions","organizations_url":"https://api.github.com/users/go-macaroon-bakery/orgs","repos_url":"https://api.github.com/users/go-macaroon-bakery/repos","events_url":"https://api.github.com/users/go-macaroon-bakery/events{/privacy}","received_events_url":"https://api.github.com/users/go-macaroon-bakery/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/go-macaroon-bakery/macaroon-bakery","description":"We bake 'em sweet, we bake 'em nice","fork":false,"url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery","forks_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/forks","keys_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/teams","hooks_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/hooks","issue_events_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/issues/events{/number}","events_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/events","assignees_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/assignees{/user}","branches_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/branches{/branch}","tags_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/tags","blobs_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/git/refs{/sha}","trees_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/statuses/{sha}","languages_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/languages","stargazers_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/stargazers","contributors_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/contributors","subscribers_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/subscribers","subscription_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/subscription","commits_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/commits{/sha}","git_commits_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/git/commits{/sha}","comments_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/comments{/number}","issue_comment_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/issues/comments{/number}","contents_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/contents/{+path}","compare_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/merges","archive_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/downloads","issues_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/issues{/number}","pulls_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls{/number}","milestones_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/milestones{/number}","notifications_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/labels{/name}","releases_url":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/releases{/id}","created_at":"2014-11-13T15:08:41Z","updated_at":"2015-06-04T11:37:00Z","pushed_at":"2015-09-30T17:26:59Z","git_url":"git://github.com/go-macaroon-bakery/macaroon-bakery.git","ssh_url":"git@github.com:go-macaroon-bakery/macaroon-bakery.git","clone_url":"https://github.com/go-macaroon-bakery/macaroon-bakery.git","svn_url":"https://github.com/go-macaroon-bakery/macaroon-bakery","homepage":null,"size":890,"stargazers_count":13,"watchers_count":13,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":4,"forks":9,"open_issues":4,"watchers":13,"default_branch":"v1"}},"_links":{"self":{"href":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/73"},"html":{"href":"https://github.com/go-macaroon-bakery/macaroon-bakery/pull/73"},"issue":{"href":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/issues/73"},"comments":{"href":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/issues/73/comments"},"review_comments":{"href":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/73/comments"},"review_comment":{"href":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/pulls/73/commits"},"statuses":{"href":"https://api.github.com/repos/go-macaroon-bakery/macaroon-bakery/statuses/50678de4fdcd869953152e20a01b2c31fa597855"}}}}