From aee0656a7c95769f63959b2e52a8e9a5636561be Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 17 Jun 2024 10:07:32 +0200 Subject: [PATCH] oprava stahovani loga obce --- ZZZO/ZZZO/ZzzoCore.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ZZZO/ZZZO/ZzzoCore.cs b/ZZZO/ZZZO/ZzzoCore.cs index e102323..b4920b2 100755 --- a/ZZZO/ZZZO/ZzzoCore.cs +++ b/ZZZO/ZZZO/ZzzoCore.cs @@ -1,5 +1,6 @@ using System.IO; using System.Net.Http; +using System.Net.Http.Headers; using HtmlAgilityPack; using Microsoft.Win32; using ZZZO.Common; @@ -141,6 +142,10 @@ public Task> DownloadCityLogos(string cityName) string baseUrl = $"{Constants.Uris.RekosBase}/vyhledani-symbolu?obec={cityName}&sort=municipality.name&page="; int pageNumber = 1; + cl.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue( + Constants.Names.AppShortName, + Constants.Names.AppBuildRevision)); + string mainHtml = cl .GetStringAsync(baseUrl + pageNumber++) .Result; @@ -197,6 +202,11 @@ public Task DownloadFullCityLogo(CityLogo cityLogo) return Task.Run(() => { using HttpClient cl = new HttpClient(); + + cl.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue( + Constants.Names.AppShortName, + Constants.Names.AppBuildRevision)); + cityLogo.LogoObceData = cl.GetByteArrayAsync(cityLogo.LogoObceUrl).Result; return cityLogo; });