Skip to content

Commit

Permalink
fix: Add -UseBasicParsing to all Invoke-WebRequest calls (#371)
Browse files Browse the repository at this point in the history
Should fix #314

Co-authored-by: Jason Clark <[email protected]>
  • Loading branch information
SuperJC710e and Jason-Clark-FG authored May 11, 2022
1 parent 17f8562 commit 47ef2c0
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ function Get-RsRestFolderContent
$url = [String]::Format($catalogItemsUri, $RsFolder)
if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $url -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -WebSession $WebSession -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $url -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -WebSession $WebSession -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}

$catalogItems = (ConvertFrom-Json $response.Content).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ function Get-RsRestItem
$catalogItemsUri = [String]::Format($catalogItemsUri, $RsItem)
if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}

$item = ConvertFrom-Json $response.Content
Expand Down Expand Up @@ -111,4 +111,4 @@ function Get-RsRestItem
}
}
New-Alias -Name "Get-RsCatalogItem" -Value Get-RsRestItem -Scope Global
New-Alias -Name "Get-RsItem" -Value Get-RsRestItem -Scope Global
New-Alias -Name "Get-RsItem" -Value Get-RsRestItem -Scope Global
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ function Get-RsRestItemDataModelParameter
$catalogItemsUri = [String]::Format($catalogItemsUri, $RsItem)
if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}

$item = ConvertFrom-Json $response.Content
Expand All @@ -99,11 +99,11 @@ function Get-RsRestItemDataModelParameter

if ($Credential -ne $null)
{
$paramResponse = Invoke-WebRequest -Uri $parametersUri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false
$paramResponse = Invoke-WebRequest -Uri $parametersUri -Method Get -WebSession $WebSession -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$paramResponse = Invoke-WebRequest -Uri $parametersUri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false
$paramResponse = Invoke-WebRequest -Uri $parametersUri -Method Get -WebSession $WebSession -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}

Write-Verbose $paramResponse
Expand All @@ -117,4 +117,4 @@ function Get-RsRestItemDataModelParameter
}
}
}
New-Alias -Name "Get-RsRestItemDataModelParameters" -Value Get-RsRestItemDataModelParameter -Scope Global
New-Alias -Name "Get-RsRestItemDataModelParameters" -Value Get-RsRestItemDataModelParameter -Scope Global
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ function Get-RsRestItemDataSource
$catalogItemsUri = [String]::Format($catalogItemsUri, $RsItem)
if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $catalogItemsUri -Method Get -WebSession $WebSession -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}

$item = ConvertFrom-Json $response.Content
Expand All @@ -102,11 +102,11 @@ function Get-RsRestItemDataSource

if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $dataSourcesUri -Method Get -WebSession $WebSession -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $dataSourcesUri -Method Get -WebSession $WebSession -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $dataSourcesUri -Method Get -WebSession $WebSession -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $dataSourcesUri -Method Get -WebSession $WebSession -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}

$itemWithDataSources = ConvertFrom-Json $response.Content
Expand All @@ -117,4 +117,4 @@ function Get-RsRestItemDataSource
throw (New-Object System.Exception("Failed to get data sources for '$RsItem': $($_.Exception.Message)", $_.Exception))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ function New-RsRestCacheRefreshPlan

if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $refreshplansUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $refreshplansUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $refreshplansUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $refreshplansUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}

Write-Verbose "Schedule payload for $RsItem was created successfully!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ function New-RsRestFolder

if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $foldersUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $foldersUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $foldersUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $foldersUri -Method Post -WebSession $WebSession -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}

Write-Verbose "Folder $TargetFolderPath was created successfully!"
Expand All @@ -106,4 +106,4 @@ function New-RsRestFolder
throw (New-Object System.Exception("Failed to create folder '$FolderName' in '$RsFolder': $($_.Exception.Message)", $_.Exception))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ function Out-RsRestCatalogItem
$url = [string]::Format($catalogItemsByPathApi, $item)
if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}
}
catch
Expand All @@ -132,4 +132,4 @@ function Out-RsRestCatalogItem
Out-RsRestCatalogItemId -RsItemInfo $itemInfo -Destination $Destination -RestApiVersion $RestApiVersion -ReportPortalUri $ReportPortalUri -Credential $Credential -WebSession $WebSession -Overwrite:$Overwrite
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ function Out-RsRestCatalogItemId
$url = [string]::Format($catalogItemContentApi, $itemId)
if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}
}
catch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ function Out-RsRestFolderContent
$url = [string]::Format($catalogItemsByPathApiV1, $RsFolder)
if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}
}
catch
Expand All @@ -128,11 +128,11 @@ function Out-RsRestFolderContent
$url = [string]::Format($folderCatalogItemsApiV1, $folder.Id)
if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}
}
catch
Expand All @@ -148,11 +148,11 @@ function Out-RsRestFolderContent
$url = [string]::Format($folderCatalogItemsApiLatest, $RsFolder)
if ($Credential -ne $null)
{
$response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -Credential $Credential -UseBasicParsing -Verbose:$false
}
else
{
$response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -Verbose:$false
$response = Invoke-WebRequest -Uri $url -Method Get -UseDefaultCredentials -UseBasicParsing -Verbose:$false
}
}
catch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ function Remove-RsRestCatalogItem

if ($Credential -ne $null)
{
Invoke-WebRequest -Uri $catalogItemsUri -Method Delete -WebSession $WebSession -Credential $Credential -Verbose:$false | Out-Null
Invoke-WebRequest -Uri $catalogItemsUri -Method Delete -WebSession $WebSession -Credential $Credential -UseBasicParsing -Verbose:$false | Out-Null
}
else
{
Invoke-WebRequest -Uri $catalogItemsUri -Method Delete -WebSession $WebSession -UseDefaultCredentials -Verbose:$false | Out-Null
Invoke-WebRequest -Uri $catalogItemsUri -Method Delete -WebSession $WebSession -UseDefaultCredentials -UseBasicParsing -Verbose:$false | Out-Null
}

Write-Verbose "Catalog item $RsItem was deleted successfully!"
Expand All @@ -91,4 +91,4 @@ function Remove-RsRestCatalogItem
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ function Set-RsRestItemDataModelParameter
Write-Verbose "Updating data model parameters for $($RsItem)..."
if ($Credential -ne $null)
{
Invoke-WebRequest -Uri $dataModelParametersUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -Credential $Credential -Verbose:$false | Out-Null
Invoke-WebRequest -Uri $dataModelParametersUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -Credential $Credential -UseBasicParsing -Verbose:$false | Out-Null
}
else
{
Invoke-WebRequest -Uri $dataModelParametersUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -UseDefaultCredentials -Verbose:$false | Out-Null
Invoke-WebRequest -Uri $dataModelParametersUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -UseDefaultCredentials -UseBasicParsing -Verbose:$false | Out-Null
}
Write-Verbose "Data model parameters were updated successfully!"
}
Expand All @@ -107,4 +107,4 @@ function Set-RsRestItemDataModelParameter
}
}
}
New-Alias -Name "Set-RsRestItemDataModelParameters" -Value Set-RsRestItemDataModelParameter -Scope Global
New-Alias -Name "Set-RsRestItemDataModelParameters" -Value Set-RsRestItemDataModelParameter -Scope Global
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ function Set-RsRestItemDataSource
Write-Verbose "Updating data sources for $($RsItem)..."
if ($Credential -ne $null)
{
Invoke-WebRequest -Uri $dataSourcesUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -Credential $Credential -Verbose:$false | Out-Null
Invoke-WebRequest -Uri $dataSourcesUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -Credential $Credential -UseBasicParsing -Verbose:$false | Out-Null
}
else
{
Invoke-WebRequest -Uri $dataSourcesUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -UseDefaultCredentials -Verbose:$false | Out-Null
Invoke-WebRequest -Uri $dataSourcesUri -Method $method -Body ([System.Text.Encoding]::UTF8.GetBytes($payloadJson)) -ContentType "application/json" -WebSession $WebSession -UseDefaultCredentials -UseBasicParsing -Verbose:$false | Out-Null
}
Write-Verbose "Data sources were updated successfully!"
}
Expand All @@ -252,4 +252,4 @@ function Set-RsRestItemDataSource
throw (New-Object System.Exception("Failed to update data sources for '$RsItem': $($_.Exception.Message)", $_.Exception))
}
}
}
}
Loading

0 comments on commit 47ef2c0

Please sign in to comment.