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

未关闭
#400 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
57/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
powershell
领域
backend

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
PowerShell
星标
251
派生
102
平均合并
2 分钟
30 天内合并 PR
4

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

OSDeploy/OSD 的其他 Issue

查看 OSDeploy/OSD 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。