Skip to content

setting HTTTP<S>_PROXY environment variable with a trailing '/' results in no ability to download #45678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
DewJunkie opened this issue May 24, 2025 · 3 comments
Assignees
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)

Comments

@DewJunkie
Copy link

Describe the bug
If there is a trailing slash in the HTTP(S)_PROXY environment variables, downloads will fail with WinHttpSetOption failed with exit code 87

This doesn't seem like a vcpkg issue, but it is the only tool that I have seen this occur. Seems the workaround it to not have a trailing slash in the proxy url. But this has bugged me for a long time, so maybe just having this issue with the workaround will be enough.

$env:HTTP_PROXY=$ENV:HTTPS_PROXY="http://localhost:8080/"

vcpkg x-download readme2.md --url https://raw.githubusercontent.com/microsoft/vcpkg/f951db4fb2eafcc5649151383c8f0f6648b4e853/README.md --sha512 21ace818d7e0f311d39c5608f0ddd1d3df5c31e6b55827bf363d459f4d102765723f805a2a599f6b70bbf6b1a6d919cbb351cce2b11904665bd24039b7b4cc3d
Downloading https://raw.githubusercontent.com/microsoft/vcpkg/f951db4fb2eafcc5649151383c8f0f6648b4e853/README.md -> readme2.md
error: https://raw.githubusercontent.com/microsoft/vcpkg/f951db4fb2eafcc5649151383c8f0f6648b4e853/README.md: WinHttpSetOption failed with exit code 87.
note: If you are using a proxy, please ensure your proxy settings are correct.
Possible causes are:
1. You are actually using an HTTP proxy, but setting HTTPS_PROXY variable to `https//address:port`.
This is not correct, because `https://` prefix claims the proxy is an HTTPS proxy, while your proxy (v2ray, shadowsocksr, etc...) is an HTTP proxy.
Try setting `http://address:port` to both HTTP_PROXY and HTTPS_PROXY instead.
2. If you are using Windows, vcpkg will automatically use your Windows IE Proxy Settings set by your proxy software. See: https://github.com/microsoft/vcpkg-tool/pull/77
The value set by your proxy might be wrong, or have same `https://` prefix issue.
3. Your proxy's remote server is our of service.
If you believe this is not a temporary download server failure and vcpkg needs to be changed to download this file from a different location, please submit an issue to https://github.com/Microsoft/vcpkg/issues
$env:HTTP_PROXY=$ENV:HTTPS_PROXY="http://localhost:8080"
vcpkg x-download readme2.md --url https://raw.githubusercontent.com/microsoft/vcpkg/f951db4fb2eafcc5649151383c8f0f6648b4e853/README.md --sha512 21ace818d7e0f311d39c5608f0ddd1d3df5c31e6b55827bf363d459f4d102765723f805a2a599f6b70bbf6b1a6d919cbb351cce2b11904665bd24039b7b4cc3d
Downloading https://raw.githubusercontent.com/microsoft/vcpkg/f951db4fb2eafcc5649151383c8f0f6648b4e853/README.md -> readme2.md
Successfully downloaded readme2.md

Environment

  • OS: Windows
  • Compiler: n/a

To Reproduce
Steps to reproduce the behavior:

  1. Set HTTP(S)_PROXY variables to a value that has a trailing /
$env:HTTP_PROXY=$ENV:HTTPS_PROXY="http://localhost:8080/"
  1. Try to download any file
vcpkg x-download readme2.md --url https://raw.githubusercontent.com/microsoft/vcpkg/f951db4fb2eafcc5649151383c8f0f6648b4e853/README.md --sha512 21ace818d7e0f311d39c5608f0ddd1d3df5c31e6b55827bf363d459f4d102765723f805a2a599f6b70bbf6b1a6d919cbb351cce2b11904665bd24039b7b4cc3d
  1. WinHttpSetOption failed with exit code 87

Expected behavior
File can be downloaded.

Failure logs
-(please attached failure logs)

Additional context
Example trying to install a package

 vcpkg install tl-generator
Computing installation plan...
warning: vcpkg appears to be in a Visual Studio prompt targeting x86 but installing for x64-windows. Consider using --triplet x86-windows or --triplet x86-uwp.
The following packages will be built and installed:
    tl-generator:x64-windows@2021-09-28
  * vcpkg-cmake:x64-windows@2024-04-23
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-windows...
-- Using %HTTP(S)_PROXY% in environment variables.
Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.43.34808/bin/Hostx64/x64/cl.exe
Restored 0 package(s) from C:\Users\duane\AppData\Local\vcpkg\archives in 603 us. Use --debug to see more details.
Installing 1/2 vcpkg-cmake:x64-windows@2024-04-23...
Building vcpkg-cmake:x64-windows@2024-04-23...
-- Installing: D:/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_configure.cmake
-- Installing: D:/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_build.cmake
-- Installing: D:/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg_cmake_install.cmake
-- Installing: D:/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/vcpkg-port-config.cmake
-- Installing: D:/vcpkg/packages/vcpkg-cmake_x64-windows/share/vcpkg-cmake/copyright
-- Performing post-build validation
Starting submission of vcpkg-cmake:x64-windows@2024-04-23 to 1 binary cache(s) in the background
Elapsed time to handle vcpkg-cmake:x64-windows: 49.2 ms
vcpkg-cmake:x64-windows package ABI: 59562224d2b58705abf725be052b6e81ae510f6ab612c5103a7305cc7e6152d5
Installing 2/2 tl-generator:x64-windows@2021-09-28...
Building tl-generator:x64-windows@2021-09-28...
Downloading https://github.com/TartanLlama/generator/archive/a8e421f04159199f6896b09cad2bd3c6fbb2a5fb.tar.gz -> TartanLlama-generator-a8e421f04159199f6896b09cad2bd3c6fbb2a5fb.tar.gz
error: https://github.com/TartanLlama/generator/archive/a8e421f04159199f6896b09cad2bd3c6fbb2a5fb.tar.gz: WinHttpSetOption failed with exit code 87.
@DewJunkie
Copy link
Author

Fixed with microsoft/vcpkg-tool#1690

@Mengna-Li Mengna-Li added the category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) label May 26, 2025
@BillyONeal
Copy link
Member

BillyONeal commented May 26, 2025

What does curl.exe do in this condition? I wouldn't be surprised for a trailing / to be forbidden because I don't believe a proxy gets a Location: but I super duper don't know what I'm talking about when it comes to proxies...

@DewJunkie
Copy link
Author

It just works. vcpkg is the only tool that has failed due to having my proxy set like this, I was assuming it was because our coprorate proxy did something odd, but I decided to try it at home with mitm proxy to see if I could figure out what was going on. I have since update to remove the trailing slash. But I thought it worth mentioning in case there was anyone else scratching their head about what was going on.

curl http://google.com -x http://localhost:8080/
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
 $env:HTTP_PROXY=$ENV:HTTPS_PROXY="http://localhost:8080/"
curl http://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`)
Projects
None yet
Development

No branches or pull requests

3 participants