-
Notifications
You must be signed in to change notification settings - Fork 21
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
Can't download mpc-be #19
Comments
It looks like a proxy is required to download the files in this package. It looks like chocolatey has a strategy for doing this in Get-WebFile.ps1 in the chocolatey repository. I think we would have to implement something similar in our .NET code. I have no immediate plans to look at this issue further but would accept a pull request if anyone wants to look at it. |
Nope, no proxy just two simple things need to occur:
To demonstrate this issue and the solution using dotnet in Powershell: C:\temp »
λ $url='https://sourceforge.net/projects/mpcbe/files/MPC-BE/Release%20builds/1.5.1/MPC-BE.1.5.1.x64-installer.zip/download'
C:\temp »
λ $path='C:\Temp\MPC-BE.1.5.1.x64-installer.zip'
C:\temp »
λ Invoke-WebRequest -Uri $url -OutFile $path
[Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
At line:1 char:1
+ Invoke-WebRequest -Uri $url -OutFile $path
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], We
bException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand]
C:\temp »
λ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
C:\temp »
λ Invoke-WebRequest -Uri $url -OutFile $path
✘ [FAILURE: Successful download but upon opening .zip - it is really the Sourceforge HTML redirect page)]
C:\temp »
λ Invoke-WebRequest -Uri $url -OutFile $path -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::Chrome
✔ 'SUCCESS: Fully usable/proper MPC-BE installer zip file!
So, in CSharp you would first do this: System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12; ...And then simply use any explicit useragent you want (best practice, anyway)....and along with the TLS there is no package you should not be able to download with the only single exception being the one-off's that need a very specific header sent with the request that is usually handled in the Powershell install, anyway. EDITMight as well just post the code to fix it :) I just compiled it to confirm it works, including with the very nicely done upstream fork from @sr258. System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12;
var request = (HttpWebRequest)WebRequest.Create(url);
((HttpWebRequest)request).UserAgent = "ChocolateStore"; |
I get this error when downloading mpc-be
Installs ok when installed directly
The text was updated successfully, but these errors were encountered: