Save-WebFile: curl download fails in WinPE proxy environment while Invoke-WebRequest works

Aperta
#400 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
powershell
Ambito
backend

Direzione di ricerca

Start with Public\Functions\Save-WebFile.ps1 and trace how Save-WebFile selects the WebClient and curl branches, including the header request and download command. Reproduce the reported failure in WinPE with a proxy, then compare it with the Invoke-WebRequest download that succeeds. Done means the download works through the WinPE proxy with a consistent configuration or a usable option to select the download method.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug

When using Save-WebFile from OSD 26.10.16.1 during the WinPE phase in a proxy environment, the download through curl.exe does not work.

Replacing the curl download command with Invoke-WebRequest allows the download to work in this environment.

The function already uses Invoke-WebRequest to retrieve the HTTP headers in the curl branch, but then uses curl.exe for the actual download. These two clients may use different proxy configurations.

To Reproduce

  1. Boot into WinPE in an environment where internet access requires a proxy.

  2. Load OSD 26.10.16.1.

  3. Run Save-WebFile to download a file, taking the curl download branch.

  4. The download through curl.exe fails.

  5. Replace the $curlCommandExpression assignment with:

    $curlCommandExpression = "iwr -uri `"$SourceUrl`" -outfile `"$DestinationFullName`" -UseBasicParsing"
    
  6. Repeat the download. It works using Invoke-WebRequest.

Expected behavior

Save-WebFile should download files reliably through the proxy available in the WinPE environment.

The HTTP header request and the actual download should use a consistent proxy configuration. Alternatively, the function could provide an option to use Invoke-WebRequest as the download method.

Screenshots

Not available.

Desktop (please complete the following information):

  • OS: Windows PE (WinPE), deployment phase
  • Browser: Not applicable
  • Version: OSD 26.10.16.1
  • WinPE build: Not provided
  • PowerShell version: Not provided

Smartphone (please complete the following information):

Not applicable.

Additional context

Affected function:
Save-WebFile.ps1, OSD 26.10.16.1

The function selects the WebClient branch when DefaultWebProxy.Address is populated, when -WebClient is specified, or when curl.exe is unavailable. Otherwise, it uses the curl branch.

The exact reason why the proxy configuration is usable by Invoke-WebRequest but not by the curl download still needs investigation.

This issue concerns the download implementation in Save-WebFile, independently of the direct TCP precheck in Test-WebConnection.

Lingua principale
PowerShell
Stelle
251
Fork
102
Merge medio
2m
PR unite (30g)
4

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OSDeploy/OSD

Tutte le issue di OSDeploy/OSD

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.