fix win_get_url var renames ala xpicio fix PR #2378
reimplements #2378 sans formatting merge conflicts
This commit is contained in:
parent
1a298f7948
commit
0f52ad70cd
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
|
$force = Get-Attr -obj $params -name "force" "yes" | ConvertTo-Bool
|
||||||
|
|
||||||
If ($force -or -not (Test-Path $dest)) {
|
If ($force -or -not (Test-Path $dest)) {
|
||||||
$client = New-Object System.Net.WebClient
|
$webClient = New-Object System.Net.WebClient
|
||||||
if($proxy_url) {
|
if($proxy_url) {
|
||||||
$proxy_server = New-Object System.Net.WebProxy($proxy_url, $true)
|
$proxy_server = New-Object System.Net.WebProxy($proxy_url, $true)
|
||||||
if($proxy_username -and $proxy_password){
|
if($proxy_username -and $proxy_password){
|
||||||
$proxy_credential = New-Object System.Net.NetworkCredential($proxy_username, $proxy_password)
|
$proxy_credential = New-Object System.Net.NetworkCredential($proxy_username, $proxy_password)
|
||||||
$proxy_server.Credentials = $proxy_credential
|
$proxy_server.Credentials = $proxy_credential
|
||||||
}
|
}
|
||||||
$client.Proxy = $proxy_server
|
$webClient.Proxy = $proxy_server
|
||||||
}
|
}
|
||||||
|
|
||||||
if($username -and $password){
|
if($username -and $password){
|
||||||
$client.Credentials = New-Object System.Net.NetworkCredential($username, $password)
|
$webClient.Credentials = New-Object System.Net.NetworkCredential($username, $password)
|
||||||
}
|
}
|
||||||
|
|
||||||
Try {
|
Try {
|
||||||
$client.DownloadFile($url, $dest)
|
$webClient.DownloadFile($url, $dest)
|
||||||
$result.changed = $true
|
$result.changed = $true
|
||||||
}
|
}
|
||||||
Catch {
|
Catch {
|
||||||
|
@ -89,7 +89,7 @@ Else {
|
||||||
$webRequest.Method = "GET"
|
$webRequest.Method = "GET"
|
||||||
[System.Net.HttpWebResponse]$webResponse = $webRequest.GetResponse()
|
[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
|
$stream.ReadToEnd() | Set-Content -Path $dest -Force -ErrorAction Stop
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue