Minor code improvement according to comments

pull/39/head
Nikolai Frolov (Akvelon INC) 3 years ago
parent b5a05e45d5
commit fa49641719

@ -4,11 +4,6 @@ param (
) )
$Global:validationFailed = $false $Global:validationFailed = $false
$authorizationHeaderValue = "Basic $AccessToken"
$webRequestHeaders = @{}
if ($AccessToken) {
$webRequestHeaders.Add("Authorization", $authorizationHeaderValue)
}
function Publish-Error { function Publish-Error {
param( param(
@ -16,7 +11,7 @@ function Publish-Error {
[object] $Exception [object] $Exception
) )
echo "::error ::$ErrorDescription" Write-Output "::error ::$ErrorDescription"
if (-not [string]::IsNullOrEmpty($Exception)) if (-not [string]::IsNullOrEmpty($Exception))
{ {
Write-Output "Exception: $Exception" Write-Output "Exception: $Exception"
@ -26,6 +21,7 @@ function Publish-Error {
function Test-DownloadUrl { function Test-DownloadUrl {
param([string] $DownloadUrl) param([string] $DownloadUrl)
$authorizationHeaderValue = "Basic $AccessToken"
$request = [System.Net.WebRequest]::Create($DownloadUrl) $request = [System.Net.WebRequest]::Create($DownloadUrl)
if ($AccessToken) { if ($AccessToken) {
$request.Headers.Add("Authorization", $authorizationHeaderValue) $request.Headers.Add("Authorization", $authorizationHeaderValue)

Loading…
Cancel
Save