{"action":"created","comment":{"url":"https://api.github.com/repos/octokit/octokit.net/pulls/comments/69546655","id":69546655,"diff_hunk":"@@ -42,10 +44,99 @@ public HttpClientAdapter(Func<HttpMessageHandler> getHandler)\n \n             using (var requestMessage = BuildRequestMessage(request))\n             {\n-                // Make the request\n-                var responseMessage = await _http.SendAsync(requestMessage, HttpCompletionOption.ResponseContentRead, cancellationTokenForRequest).ConfigureAwait(false);\n-                return await BuildResponse(responseMessage).ConfigureAwait(false);\n+                var response = await GetSuccessfulResponse(requestMessage, cancellationTokenForRequest);\n+\n+                return await BuildResponse(response).ConfigureAwait(false);\n+            }\n+        }\n+\n+        private async Task<HttpResponseMessage> GetSuccessfulResponse(HttpRequestMessage request, CancellationToken cancellationToken)\n+        {\n+            var response = await SendRequest(request, cancellationToken).ConfigureAwait(false);\n+\n+            // Can't redirect without somewhere to redirect too.  Throw?\n+            if (response.Headers.Location == null) return response;\n+\n+            // Don't redirect if we exceed max number of redirects\n+            var redirectCount = 0;\n+            if (request.Properties.Keys.Contains(RedirectCountKey))\n+            {\n+                redirectCount = (int)request.Properties[RedirectCountKey];\n+            }\n+            if (redirectCount > 3)\n+            {\n+                throw new InvalidOperationException(\"The redirect count for this request has been exceeded. Aborting.\");\n+            }\n+            request.Properties[RedirectCountKey] = ++redirectCount;\n+\n+            if (response.StatusCode == HttpStatusCode.MovedPermanently\n+                        || response.StatusCode == HttpStatusCode.Redirect\n+                        || response.StatusCode == HttpStatusCode.Found\n+                        || response.StatusCode == HttpStatusCode.SeeOther\n+                        || response.StatusCode == HttpStatusCode.TemporaryRedirect\n+                        || (int)response.StatusCode == 308)\n+            {\n+                var newRequest = CopyRequest(request);\n+\n+                if (response.StatusCode == HttpStatusCode.SeeOther)\n+                {\n+                    request.Content = null;\n+                    request.Method = HttpMethod.Get;","path":"Octokit/Http/HttpClientAdapter.cs","position":53,"original_position":53,"commit_id":"f3efff1dea6ddba22b810b0eecceccac20d644f8","original_commit_id":"f3efff1dea6ddba22b810b0eecceccac20d644f8","user":{"login":"ryangribble","id":5425163,"avatar_url":"https://avatars.githubusercontent.com/u/5425163?v=3","gravatar_id":"","url":"https://api.github.com/users/ryangribble","html_url":"https://github.com/ryangribble","followers_url":"https://api.github.com/users/ryangribble/followers","following_url":"https://api.github.com/users/ryangribble/following{/other_user}","gists_url":"https://api.github.com/users/ryangribble/gists{/gist_id}","starred_url":"https://api.github.com/users/ryangribble/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryangribble/subscriptions","organizations_url":"https://api.github.com/users/ryangribble/orgs","repos_url":"https://api.github.com/users/ryangribble/repos","events_url":"https://api.github.com/users/ryangribble/events{/privacy}","received_events_url":"https://api.github.com/users/ryangribble/received_events","type":"User","site_admin":false},"body":"Is this intentional?  the old code was `newRequest` here rather than `request`","created_at":"2016-07-05T11:23:13Z","updated_at":"2016-07-05T11:23:13Z","html_url":"https://github.com/octokit/octokit.net/pull/1411#discussion_r69546655","pull_request_url":"https://api.github.com/repos/octokit/octokit.net/pulls/1411","_links":{"self":{"href":"https://api.github.com/repos/octokit/octokit.net/pulls/comments/69546655"},"html":{"href":"https://github.com/octokit/octokit.net/pull/1411#discussion_r69546655"},"pull_request":{"href":"https://api.github.com/repos/octokit/octokit.net/pulls/1411"}}},"pull_request":{"url":"https://api.github.com/repos/octokit/octokit.net/pulls/1411","id":76235973,"html_url":"https://github.com/octokit/octokit.net/pull/1411","diff_url":"https://github.com/octokit/octokit.net/pull/1411.diff","patch_url":"https://github.com/octokit/octokit.net/pull/1411.patch","issue_url":"https://api.github.com/repos/octokit/octokit.net/issues/1411","number":1411,"state":"open","locked":false,"title":"Fix timeout getting multiple repositories","user":{"login":"maddin2016","id":19551763,"avatar_url":"https://avatars.githubusercontent.com/u/19551763?v=3","gravatar_id":"","url":"https://api.github.com/users/maddin2016","html_url":"https://github.com/maddin2016","followers_url":"https://api.github.com/users/maddin2016/followers","following_url":"https://api.github.com/users/maddin2016/following{/other_user}","gists_url":"https://api.github.com/users/maddin2016/gists{/gist_id}","starred_url":"https://api.github.com/users/maddin2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maddin2016/subscriptions","organizations_url":"https://api.github.com/users/maddin2016/orgs","repos_url":"https://api.github.com/users/maddin2016/repos","events_url":"https://api.github.com/users/maddin2016/events{/privacy}","received_events_url":"https://api.github.com/users/maddin2016/received_events","type":"User","site_admin":false},"body":"fixed #1396 \r\n\r\nPut logic for redirects outside delegatinghandler in `HttpClientAdapter`.","created_at":"2016-07-05T08:34:45Z","updated_at":"2016-07-05T11:23:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"53af6d3603be5fdce63def40d011dd8085a9d6db","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/octokit/octokit.net/pulls/1411/commits","review_comments_url":"https://api.github.com/repos/octokit/octokit.net/pulls/1411/comments","review_comment_url":"https://api.github.com/repos/octokit/octokit.net/pulls/comments{/number}","comments_url":"https://api.github.com/repos/octokit/octokit.net/issues/1411/comments","statuses_url":"https://api.github.com/repos/octokit/octokit.net/statuses/f3efff1dea6ddba22b810b0eecceccac20d644f8","head":{"label":"maddin2016:fix-timeout-getting-multiple-repositories","ref":"fix-timeout-getting-multiple-repositories","sha":"f3efff1dea6ddba22b810b0eecceccac20d644f8","user":{"login":"maddin2016","id":19551763,"avatar_url":"https://avatars.githubusercontent.com/u/19551763?v=3","gravatar_id":"","url":"https://api.github.com/users/maddin2016","html_url":"https://github.com/maddin2016","followers_url":"https://api.github.com/users/maddin2016/followers","following_url":"https://api.github.com/users/maddin2016/following{/other_user}","gists_url":"https://api.github.com/users/maddin2016/gists{/gist_id}","starred_url":"https://api.github.com/users/maddin2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maddin2016/subscriptions","organizations_url":"https://api.github.com/users/maddin2016/orgs","repos_url":"https://api.github.com/users/maddin2016/repos","events_url":"https://api.github.com/users/maddin2016/events{/privacy}","received_events_url":"https://api.github.com/users/maddin2016/received_events","type":"User","site_admin":false},"repo":{"id":59650191,"name":"octokit.net","full_name":"maddin2016/octokit.net","owner":{"login":"maddin2016","id":19551763,"avatar_url":"https://avatars.githubusercontent.com/u/19551763?v=3","gravatar_id":"","url":"https://api.github.com/users/maddin2016","html_url":"https://github.com/maddin2016","followers_url":"https://api.github.com/users/maddin2016/followers","following_url":"https://api.github.com/users/maddin2016/following{/other_user}","gists_url":"https://api.github.com/users/maddin2016/gists{/gist_id}","starred_url":"https://api.github.com/users/maddin2016/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maddin2016/subscriptions","organizations_url":"https://api.github.com/users/maddin2016/orgs","repos_url":"https://api.github.com/users/maddin2016/repos","events_url":"https://api.github.com/users/maddin2016/events{/privacy}","received_events_url":"https://api.github.com/users/maddin2016/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maddin2016/octokit.net","description":"A GitHub API client library for .NET ","fork":true,"url":"https://api.github.com/repos/maddin2016/octokit.net","forks_url":"https://api.github.com/repos/maddin2016/octokit.net/forks","keys_url":"https://api.github.com/repos/maddin2016/octokit.net/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maddin2016/octokit.net/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maddin2016/octokit.net/teams","hooks_url":"https://api.github.com/repos/maddin2016/octokit.net/hooks","issue_events_url":"https://api.github.com/repos/maddin2016/octokit.net/issues/events{/number}","events_url":"https://api.github.com/repos/maddin2016/octokit.net/events","assignees_url":"https://api.github.com/repos/maddin2016/octokit.net/assignees{/user}","branches_url":"https://api.github.com/repos/maddin2016/octokit.net/branches{/branch}","tags_url":"https://api.github.com/repos/maddin2016/octokit.net/tags","blobs_url":"https://api.github.com/repos/maddin2016/octokit.net/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maddin2016/octokit.net/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maddin2016/octokit.net/git/refs{/sha}","trees_url":"https://api.github.com/repos/maddin2016/octokit.net/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maddin2016/octokit.net/statuses/{sha}","languages_url":"https://api.github.com/repos/maddin2016/octokit.net/languages","stargazers_url":"https://api.github.com/repos/maddin2016/octokit.net/stargazers","contributors_url":"https://api.github.com/repos/maddin2016/octokit.net/contributors","subscribers_url":"https://api.github.com/repos/maddin2016/octokit.net/subscribers","subscription_url":"https://api.github.com/repos/maddin2016/octokit.net/subscription","commits_url":"https://api.github.com/repos/maddin2016/octokit.net/commits{/sha}","git_commits_url":"https://api.github.com/repos/maddin2016/octokit.net/git/commits{/sha}","comments_url":"https://api.github.com/repos/maddin2016/octokit.net/comments{/number}","issue_comment_url":"https://api.github.com/repos/maddin2016/octokit.net/issues/comments{/number}","contents_url":"https://api.github.com/repos/maddin2016/octokit.net/contents/{+path}","compare_url":"https://api.github.com/repos/maddin2016/octokit.net/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maddin2016/octokit.net/merges","archive_url":"https://api.github.com/repos/maddin2016/octokit.net/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maddin2016/octokit.net/downloads","issues_url":"https://api.github.com/repos/maddin2016/octokit.net/issues{/number}","pulls_url":"https://api.github.com/repos/maddin2016/octokit.net/pulls{/number}","milestones_url":"https://api.github.com/repos/maddin2016/octokit.net/milestones{/number}","notifications_url":"https://api.github.com/repos/maddin2016/octokit.net/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maddin2016/octokit.net/labels{/name}","releases_url":"https://api.github.com/repos/maddin2016/octokit.net/releases{/id}","deployments_url":"https://api.github.com/repos/maddin2016/octokit.net/deployments","created_at":"2016-05-25T09:31:26Z","updated_at":"2016-05-25T09:31:29Z","pushed_at":"2016-07-05T08:57:23Z","git_url":"git://github.com/maddin2016/octokit.net.git","ssh_url":"git@github.com:maddin2016/octokit.net.git","clone_url":"https://github.com/maddin2016/octokit.net.git","svn_url":"https://github.com/maddin2016/octokit.net","homepage":null,"size":84615,"stargazers_count":0,"watchers_count":0,"language":"C#","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":"octokit:master","ref":"master","sha":"e701ae763c30758fe2c4a87c4f844db0c8afa3ea","user":{"login":"octokit","id":3430433,"avatar_url":"https://avatars.githubusercontent.com/u/3430433?v=3","gravatar_id":"","url":"https://api.github.com/users/octokit","html_url":"https://github.com/octokit","followers_url":"https://api.github.com/users/octokit/followers","following_url":"https://api.github.com/users/octokit/following{/other_user}","gists_url":"https://api.github.com/users/octokit/gists{/gist_id}","starred_url":"https://api.github.com/users/octokit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octokit/subscriptions","organizations_url":"https://api.github.com/users/octokit/orgs","repos_url":"https://api.github.com/users/octokit/repos","events_url":"https://api.github.com/users/octokit/events{/privacy}","received_events_url":"https://api.github.com/users/octokit/received_events","type":"Organization","site_admin":false},"repo":{"id":7528679,"name":"octokit.net","full_name":"octokit/octokit.net","owner":{"login":"octokit","id":3430433,"avatar_url":"https://avatars.githubusercontent.com/u/3430433?v=3","gravatar_id":"","url":"https://api.github.com/users/octokit","html_url":"https://github.com/octokit","followers_url":"https://api.github.com/users/octokit/followers","following_url":"https://api.github.com/users/octokit/following{/other_user}","gists_url":"https://api.github.com/users/octokit/gists{/gist_id}","starred_url":"https://api.github.com/users/octokit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/octokit/subscriptions","organizations_url":"https://api.github.com/users/octokit/orgs","repos_url":"https://api.github.com/users/octokit/repos","events_url":"https://api.github.com/users/octokit/events{/privacy}","received_events_url":"https://api.github.com/users/octokit/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/octokit/octokit.net","description":"A GitHub API client library for .NET ","fork":false,"url":"https://api.github.com/repos/octokit/octokit.net","forks_url":"https://api.github.com/repos/octokit/octokit.net/forks","keys_url":"https://api.github.com/repos/octokit/octokit.net/keys{/key_id}","collaborators_url":"https://api.github.com/repos/octokit/octokit.net/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/octokit/octokit.net/teams","hooks_url":"https://api.github.com/repos/octokit/octokit.net/hooks","issue_events_url":"https://api.github.com/repos/octokit/octokit.net/issues/events{/number}","events_url":"https://api.github.com/repos/octokit/octokit.net/events","assignees_url":"https://api.github.com/repos/octokit/octokit.net/assignees{/user}","branches_url":"https://api.github.com/repos/octokit/octokit.net/branches{/branch}","tags_url":"https://api.github.com/repos/octokit/octokit.net/tags","blobs_url":"https://api.github.com/repos/octokit/octokit.net/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/octokit/octokit.net/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/octokit/octokit.net/git/refs{/sha}","trees_url":"https://api.github.com/repos/octokit/octokit.net/git/trees{/sha}","statuses_url":"https://api.github.com/repos/octokit/octokit.net/statuses/{sha}","languages_url":"https://api.github.com/repos/octokit/octokit.net/languages","stargazers_url":"https://api.github.com/repos/octokit/octokit.net/stargazers","contributors_url":"https://api.github.com/repos/octokit/octokit.net/contributors","subscribers_url":"https://api.github.com/repos/octokit/octokit.net/subscribers","subscription_url":"https://api.github.com/repos/octokit/octokit.net/subscription","commits_url":"https://api.github.com/repos/octokit/octokit.net/commits{/sha}","git_commits_url":"https://api.github.com/repos/octokit/octokit.net/git/commits{/sha}","comments_url":"https://api.github.com/repos/octokit/octokit.net/comments{/number}","issue_comment_url":"https://api.github.com/repos/octokit/octokit.net/issues/comments{/number}","contents_url":"https://api.github.com/repos/octokit/octokit.net/contents/{+path}","compare_url":"https://api.github.com/repos/octokit/octokit.net/compare/{base}...{head}","merges_url":"https://api.github.com/repos/octokit/octokit.net/merges","archive_url":"https://api.github.com/repos/octokit/octokit.net/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/octokit/octokit.net/downloads","issues_url":"https://api.github.com/repos/octokit/octokit.net/issues{/number}","pulls_url":"https://api.github.com/repos/octokit/octokit.net/pulls{/number}","milestones_url":"https://api.github.com/repos/octokit/octokit.net/milestones{/number}","notifications_url":"https://api.github.com/repos/octokit/octokit.net/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/octokit/octokit.net/labels{/name}","releases_url":"https://api.github.com/repos/octokit/octokit.net/releases{/id}","deployments_url":"https://api.github.com/repos/octokit/octokit.net/deployments","created_at":"2013-01-09T20:48:45Z","updated_at":"2016-07-03T20:36:19Z","pushed_at":"2016-07-05T08:57:24Z","git_url":"git://github.com/octokit/octokit.net.git","ssh_url":"git@github.com:octokit/octokit.net.git","clone_url":"https://github.com/octokit/octokit.net.git","svn_url":"https://github.com/octokit/octokit.net","homepage":null,"size":92280,"stargazers_count":989,"watchers_count":989,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":499,"mirror_url":null,"open_issues_count":132,"forks":499,"open_issues":132,"watchers":989,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/octokit/octokit.net/pulls/1411"},"html":{"href":"https://github.com/octokit/octokit.net/pull/1411"},"issue":{"href":"https://api.github.com/repos/octokit/octokit.net/issues/1411"},"comments":{"href":"https://api.github.com/repos/octokit/octokit.net/issues/1411/comments"},"review_comments":{"href":"https://api.github.com/repos/octokit/octokit.net/pulls/1411/comments"},"review_comment":{"href":"https://api.github.com/repos/octokit/octokit.net/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/octokit/octokit.net/pulls/1411/commits"},"statuses":{"href":"https://api.github.com/repos/octokit/octokit.net/statuses/f3efff1dea6ddba22b810b0eecceccac20d644f8"}}}}
{"actor":{"display_login":"ryangribble"}}