From dc889c24862c90783f2ab9cb16057866a2ea065b Mon Sep 17 00:00:00 2001 From: Kaleb Luedtke Date: Thu, 27 Jan 2022 13:03:35 -0600 Subject: [PATCH] Fix: Add UserAgent (#43164) * Resolves Trenly/winget-pkgs#142 --- Tools/YamlCreate.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tools/YamlCreate.ps1 b/Tools/YamlCreate.ps1 index c8cae14fa51e3..7f04ae9be7960 100644 --- a/Tools/YamlCreate.ps1 +++ b/Tools/YamlCreate.ps1 @@ -294,6 +294,7 @@ Function Test-Url { ) try { $HTTP_Request = [System.Net.WebRequest]::Create($URL) + $HTTP_Request.UserAgent = "Microsoft-Delivery-Optimization/10.1" $HTTP_Response = $HTTP_Request.GetResponse() $HTTP_Status = [int]$HTTP_Response.StatusCode } catch { @@ -358,6 +359,7 @@ Function Get-InstallerFile { # Create a new web client for downloading the file $_WebClient = [System.Net.WebClient]::new() + $_WebClient.Headers.Add("User-Agent", "Microsoft-Delivery-Optimization/10.1") # If the system has a default proxy set, use it # Powershell Core will automatically use this, so it's only necessary for PS5 if ($PSVersionTable.PSVersion.Major -lt 6) { $_WebClient.Proxy = [System.Net.WebProxy]::GetDefaultProxy() }