Skip to content

Can't download URLs that require special headers, eg. audacity-lame #18

@laggingreflex

Description

@laggingreflex

I get this error when downloading audacity-lame

Reading package 'audacity-lame'
package URL: 'https://chocolatey.org/api/v2/package/audacity-lame/3.99.3.20171217'
Downloading: audacity-lame.3.99.3.20171217.nupkg
Download Failed: https://lame.buanzo.org/Lame_v3.99.3_for_Windows.exe
System.Net.WebException: The remote server returned an error: (403) Forbidden.
   at System.Net.HttpWebRequest.GetResponse()
   at ChocolateStore.PackageCacher.DownloadFile(String url, String destination) in C:\...\ChocolateStore\src\ChocolateStore\PackageCacher.cs:line 83
Downloading:
Download Failed: https://lame.buanzo.org/
System.UnauthorizedAccessException: Access to the path 'D:\...\source\audacity-lame' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.Create(String path)
   at ChocolateStore.PackageCacher.DownloadFile(String url, String destination) in C:\...\ChocolateStore\src\ChocolateStore\PackageCacher.cs:line 94

It seems like it requires some headers to be acquired from their homepage before downloading the installer otherwise it results in a 403. This seems to be specified in it's install file:

chocolateyInstall.ps1

$options =
@{
  Headers = @{
    Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
    Referer = 'https://lame.buanzo.org/';
  }
}

When installing directly there's an error at first but it tries again and downloads correctly

Installing the following packages:
audacity-lame
By installing you accept licenses for the packages.
Progress: Downloading audacity-lame 3.99.3.20171217... 100%

audacity-lame v3.99.3.20171217 [Approved]
audacity-lame package files install completed. Performing other installation steps.
Attempt to get headers for https://lame.buanzo.org/Lame_v3.99.3_for_Windows.exe failed.
  The remote file either doesn't exist, is unauthorized, or is forbidden for url 'https://lame.buanzo.org/Lame_v3.99.3_for_Windows.exe'. Exception calling "GetResponse" with "0" argument(s): "The remote server returned an error: (403) Forbidden."
Downloading audacity-lame
  from 'https://lame.buanzo.org/Lame_v3.99.3_for_Windows.exe'
Progress: 100% - Completed download of C:\Users\x\AppData\Local\Temp\chocolatey\audacity-lame\3.99.3.20171217\audacity-lameInstall.EXE (515.06 KB).
Download of audacity-lameInstall.EXE (515.06 KB) completed.
Hashes match.
Installing audacity-lame...
audacity-lame has been installed.
  audacity-lame can be automatically uninstalled.
 The install of audacity-lame was successful.
  Software installed to 'C:\Program Files (x86)\Lame For Audacity\'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions