Skip to content

Commit 23b3e12

Browse files
authored
Fix Invoke-WebRequest IDictionary cast error. (#297)
Originally fixed in #292 Co-authored-by: badassletchu@gmail.com
1 parent 4a8e8b2 commit 23b3e12

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/manage/urlutils.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,15 @@ def _powershell_urlretrieve(request):
294294
$url = $env:PYMANAGER_URL
295295
$outfile = $env:PYMANAGER_OUTFILE
296296
$method = $env:PYMANAGER_METHOD
297-
$headers = ConvertFrom-Json $env:PYMANAGER_HEADERS
297+
$headersObj = ConvertFrom-Json $env:PYMANAGER_HEADERS
298+
$headers = @{}
299+
if ($headersObj -ne $null) {
300+
$headersObj.PSObject.Properties | ForEach-Object {
301+
$name = $_.Name
302+
$value = $_.Value
303+
$headers[$name] = if ($value -eq $null) { "" } else { $value.ToString() }
304+
}
305+
}
298306
$r = Invoke-WebRequest -Uri $url -UseBasicParsing `
299307
-Headers $headers `
300308
-UseDefaultCredentials `

0 commit comments

Comments
 (0)