Removed default User-Agent header.

Using a library's default User-Agent violates OpenStreetMap's tile usage policy: https://operations.osmfoundation.org/policies/tiles/
This commit is contained in:
ClemensFischer 2026-01-21 22:33:05 +01:00
parent 8124d5714a
commit 66a51906ef
10 changed files with 67 additions and 30 deletions

View file

@ -23,19 +23,15 @@ namespace MapControl
/// <summary>
/// The System.Net.Http.HttpClient instance used to download images.
/// An application should add a unique User-Agent value to the DefaultRequestHeaders of this
/// HttpClient instance (or the Headers of a HttpRequestMessage used in a HttpMessageHandler).
/// Failing to set a unique User-Agent value is a violation of OpenStreetMap's tile usage policy
/// (see https://operations.osmfoundation.org/policies/tiles/) and results in blocked access
/// to their tile servers.
/// </summary>
public static HttpClient HttpClient
{
get
{
if (field == null)
{
field = new HttpClient { Timeout = TimeSpan.FromSeconds(10) };
field.DefaultRequestHeaders.Add("User-Agent", $"XAML-Map-Control/{typeof(ImageLoader).Assembly.GetName().Version}");
}
return field;
}
get => field ??= new HttpClient { Timeout = TimeSpan.FromSeconds(10) };
set;
}