mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fix win_get_url var renames ala xpicio fix PR #2378
reimplements #2378 sans formatting merge conflicts
This commit is contained in:
parent
7be08b00b0
commit
821fb6c0ab
1 changed files with 5 additions and 5 deletions
|
@ -55,22 +55,22 @@ if($skip_certificate_validation){
|
|||
$force = Get-Attr -obj $params -name "force" "yes" | ConvertTo-Bool
|
||||
|
||||
If ($force -or -not (Test-Path $dest)) {
|
||||
$client = New-Object System.Net.WebClient
|
||||
$webClient = New-Object System.Net.WebClient
|
||||
if($proxy_url) {
|
||||
$proxy_server = New-Object System.Net.WebProxy($proxy_url, $true)
|
||||
if($proxy_username -and $proxy_password){
|
||||
$proxy_credential = New-Object System.Net.NetworkCredential($proxy_username, $proxy_password)
|
||||
$proxy_server.Credentials = $proxy_credential
|
||||
}
|
||||
$client.Proxy = $proxy_server
|
||||
$webClient.Proxy = $proxy_server
|
||||
}
|
||||
|
||||
if($username -and $password){
|
||||
$client.Credentials = New-Object System.Net.NetworkCredential($username, $password)
|
||||
$webClient.Credentials = New-Object System.Net.NetworkCredential($username, $password)
|
||||
}
|
||||
|
||||
Try {
|
||||
$client.DownloadFile($url, $dest)
|
||||
$webClient.DownloadFile($url, $dest)
|
||||
$result.changed = $true
|
||||
}
|
||||
Catch {
|
||||
|
@ -89,7 +89,7 @@ Else {
|
|||
$webRequest.Method = "GET"
|
||||
[System.Net.HttpWebResponse]$webResponse = $webRequest.GetResponse()
|
||||
|
||||
$stream = New-Object System.IO.StreamReader($response.GetResponseStream())
|
||||
$stream = New-Object System.IO.StreamReader($webResponse.GetResponseStream())
|
||||
|
||||
$stream.ReadToEnd() | Set-Content -Path $dest -Force -ErrorAction Stop
|
||||
|
||||
|
|
Loading…
Reference in a new issue