GithubHelp home page GithubHelp logo

Can't download mpc-be about chocolatestore HOT 2 OPEN

bahkoo avatar bahkoo commented on August 11, 2024
Can't download mpc-be

from chocolatestore.

Comments (2)

BahKoo avatar BahKoo commented on August 11, 2024

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.

from chocolatestore.

CollinChaffin avatar CollinChaffin commented on August 11, 2024

Nope, no proxy just two simple things need to occur:

  1. Set up TLS1.2 (the root cause of your failure above)
  2. MUST set the user-agent properly (if you had gotten this far, by default you would only get the SF page as your file without this)

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.

EDIT

Might 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";

from chocolatestore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.