Skip to content
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

HttpEnvironmentProxy fails when proxy URI contains trailing slash #27543

Closed
markekraus opened this issue Oct 5, 2018 · 6 comments
Closed

HttpEnvironmentProxy fails when proxy URI contains trailing slash #27543

markekraus opened this issue Oct 5, 2018 · 6 comments

Comments

@markekraus
Copy link

On linux, if the http_proxy or https_proxy environment variables contain a trailing slash, the proxy will not be used.

This can be reproed with PowerShell 6.1.0:

$assembly = [System.Net.Http.HttpClientHandler].Assembly
$class = $assembly.GetType('System.Net.Http.HttpEnvironmentProxy')
$method = $class.GetMethod('TryCreate')
$proxy = [System.Net.WebProxy]::new()
$env:HTTPS_PROXY = 'http://webproxy:3128/'
$method.Invoke($null, @($proxy))

it should be True, instead it is False.

However, if the trailing slash is removed, TryCreate() works:

$assembly = [System.Net.Http.HttpClientHandler].Assembly
$class = $assembly.GetType('System.Net.Http.HttpEnvironmentProxy')
$method = $class.GetMethod('TryCreate')
$proxy = [System.Net.WebProxy]::new()
# No trailing slash
$env:HTTPS_PROXY = 'http://webproxy:3128'
$method.Invoke($null, @($proxy))

The issue appears to be in GetUriFromString.

$assembly = [System.Net.Http.HttpClientHandler].Assembly
$class = $assembly.GetType('System.Net.Http.HttpEnvironmentProxy')
$Method = $class.GetMethod('GetUriFromString',[System.Reflection.BindingFlags]'NonPublic, Static')
$Method.Invoke($null, @('http://webproxy:3128'))

Returns a uri

$Method.Invoke($null, @('http://webproxy:3128/'))

returns null.

@markekraus markekraus changed the title HttpEnvironmentProxy fails whtn proxy URI contains trailing slash HttpEnvironmentProxy fails when proxy URI contains trailing slash Oct 5, 2018
@stephentoub
Copy link
Member

This looks like a dup of https://github.com/dotnet/corefx/issues/31326, which was fixed by dotnet/corefx#31232 and dotnet/corefx#31327.

@iSazonov
Copy link
Contributor

iSazonov commented Oct 5, 2018

@stephentoub Is the fix in .Net Core 2.1.5?

@stephentoub
Copy link
Member

I believe so. What version are you using?

@iSazonov
Copy link
Contributor

iSazonov commented Oct 5, 2018

We moved to .Net Core 2.1.5 in PowerShell master branch but @markekraus repo script doesn't work for me and I can not confirm that fix works.

@iSazonov
Copy link
Contributor

iSazonov commented Oct 5, 2018

@davidsh
Copy link
Contributor

davidsh commented Oct 5, 2018

Duplicate of #26938.

@davidsh davidsh closed this as completed Oct 5, 2018
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants