Merge pull request #4582 from crobibero/music-client

Use proper Named HttpClient for MusicBrainz requests
This commit is contained in:
Claus Vium 2020-11-26 10:32:09 +01:00 committed by GitHub
commit 32822ef9e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -768,16 +768,7 @@ namespace MediaBrowser.Providers.Music
_stopWatchMusicBrainz.Restart(); _stopWatchMusicBrainz.Restart();
using var request = new HttpRequestMessage(HttpMethod.Get, requestUrl); using var request = new HttpRequestMessage(HttpMethod.Get, requestUrl);
response = await _httpClientFactory.CreateClient(NamedClient.MusicBrainz).SendAsync(request).ConfigureAwait(false);
// MusicBrainz request a contact email address is supplied, as comment, in user agent field:
// https://musicbrainz.org/doc/XML_Web_Service/Rate_Limiting#User-Agent .
request.Headers.UserAgent.ParseAdd(string.Format(
CultureInfo.InvariantCulture,
"{0} ( {1} )",
_appHost.ApplicationUserAgent,
_appHost.ApplicationUserAgentAddress));
response = await _httpClientFactory.CreateClient(NamedClient.Default).SendAsync(request).ConfigureAwait(false);
// We retry a finite number of times, and only whilst MB is indicating 503 (throttling). // We retry a finite number of times, and only whilst MB is indicating 503 (throttling).
} }