mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
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:
parent
8124d5714a
commit
66a51906ef
10 changed files with 67 additions and 30 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue