예제 #1
0
 public ReleaseDownloader(IReleaseDownloaderSettings settings)
 {
     _settings = settings.Copy();
     _settings.HTTPClient.DefaultRequestHeaders.Add("User-Agent", _settings.Repository);
     _releasesEndpoint = "https://api.github.com/repos/" + _settings.Author + "/" + _settings.Repository +
                         "/releases";
 }
예제 #2
0
 public ReleaseDownloader(IReleaseDownloaderSettings settings, HttpClient httpClient) : this(settings)
 {
     // Check User Using Custom httpClient himself.
     if (httpClient.DefaultRequestHeaders.UserAgent.Any())
     {
         this.HttpClient.Dispose();
         this.HttpClient = httpClient;
     }
 }
예제 #3
0
        public ReleaseDownloader(IReleaseDownloaderSettings settings)
        {
            _settings = settings.Copy();

            HttpClient = new HttpClient();
            var assemblyName = Assembly.GetExecutingAssembly().GetName();

            HttpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue(new ProductHeaderValue(assemblyName.Name, assemblyName.Version.ToString())));
            HttpClient.DefaultRequestHeaders.Add("Accept", "application/vnd.github.v3.raw");
            if (!string.IsNullOrEmpty(_settings.PAT))
            {
                HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("token", _settings.PAT);
            }
        }