carolynvs / chocolatey-packages

Packages for Chocolatey
1 stars 0 forks source link

407: Proxy Authentication Required from behind proxy requiring authentication #3

Open alangibson opened 9 years ago

alangibson commented 9 years ago

Hello,

Trying to install java.jdk from behind a proxy requiring authentication produces the following error

Downloading JDK from http://download.oracle.com/otn-pub/java/jdk/7u60-b19/jdk-7u60-windows-x64.exe
Write-Error : Java.JDK did not finish successfully. Boo to the chocolatey gods!
-----------------------
[ERROR] The remote server returned an error: (407) Proxy Authentication Required.
-----------------------
At C:\ProgramData\chocolatey\chocolateyinstall\helpers\functions\Write-ChocolateyFailure.ps1:30 char:14
+   Write-Error <<<<  $errorMessage
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Error

Write-Error : Package 'java.jdk v7.0.60.1' did not install successfully: Exception calling "DownloadFile" with "2" argument(s): "The remote server returned an error: (407) Proxy Authentication Required."
At C:\ProgramData\chocolatey\chocolateyinstall\functions\Chocolatey-NuGet.ps1:95 char:28
+                 Write-Error <<<<  "Package `'$installedPackageName v$installedPackageVersion`' did not install successfully: $($_.Exception.Message)"
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Error

Finished installing 'java.jdk' and dependencies - if errors not shown in console, none detected. Check log for errors if unsure.

I think the offending bit is this block from the download-from-oracle function

    $client = New-Object Net.WebClient
    $client.Headers.Add('Cookie', 'gpw_e24=http://www.oracle.com; oraclelicense=accept-securebackup-cookie')
    $client.DownloadFile($url, $output_filename)

None of the proxy credentials setup that chocolatey does in Get-WebFile is done here. I would say you could just switch to using Get-WebFile, but it looks like it does not yet support adding headers. This feature is however scheduled to be included in v0.9.9.

https://github.com/chocolatey/chocolatey/pull/171

So my request is: please consider using Get-WebFile once support for headers is added in v0.9.9.

carolynvs commented 9 years ago

Thanks for the pointer to that PR. Once Get-WebFile supports headers I would love to simplify (and hopefully consolidate) the jdk chocolatey package.