public ICollection <GithubRelease> DownloadReleases(string requestingUri) { Console.WriteLine("Requesting: {0}", requestingUri); var request = (HttpWebRequest)WebRequest.Create(new Uri(requestingUri)); request.UserAgent = _userAgent; var response = request.GetResponse(); Console.WriteLine(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server. var responseFromServer = ReadResponseFromServer(response); var releases = JsonConvert.DeserializeObject <List <GithubRelease> >(responseFromServer); var parser = new LinkHeaderParser(); var linkHeader = response.Headers["Link"]; var nextUrl = parser.GetNextPageFromHeader(linkHeader); if (!string.IsNullOrEmpty(nextUrl)) { releases.AddRange(DownloadReleases(nextUrl)); } // Clean up the streams and the response. response.Close(); return(releases); }
public ICollection<GithubRelease> DownloadReleases(string requestingUri) { Console.WriteLine("Requesting: {0}", requestingUri); var request = (HttpWebRequest) WebRequest.Create(new Uri(requestingUri)); request.UserAgent = _userAgent; var response = request.GetResponse(); Console.WriteLine(((HttpWebResponse) response).StatusDescription); // Get the stream containing content returned by the server. var responseFromServer = ReadResponseFromServer(response); var releases = JsonConvert.DeserializeObject<List<GithubRelease>>(responseFromServer); var parser = new LinkHeaderParser(); var linkHeader = response.Headers["Link"]; var nextUrl = parser.GetNextPageFromHeader(linkHeader); if (!string.IsNullOrEmpty(nextUrl)) { releases.AddRange(DownloadReleases(nextUrl)); } // Clean up the streams and the response. response.Close(); return releases; }
void GetExpectedResult(string value, string expected) { var parser = new LinkHeaderParser(); var result = parser.GetNextPageFromHeader(value); Assert.Equal(expected, result); }