You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Exception from sites that require a user agent header when calling DownloadFile() (the GitHub API is one such server that doesn't like agentless requests).
What is Expected?
A successful file download.
What version of Cake are you using?
0.16.2
Are you running on a 32 or 64 bit system?
64
What environment are you running on? Windows? Linux? Mac?
Windows
Are you running on a CI Server? If so, which one?
No
How Did You Get This To Happen? (Steps to Reproduce)
Use the following code in a task (note that you must also have Octokit as an addin for this sample):
Downloading file: https://api.github.com/repos/cake-build/cake/zipball/v0.16.2
An error occured when executing task 'GetSource'.
Error: System.AggregateException: One or more errors occurred. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The server committed a protocol violation. Section=ResponseStatusLine
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Cake.Common.Net.HttpClientExtensions.<DownloadFileAsync>d__1.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Cake.Common.Net.HttpAliases.DownloadFile(ICakeContext context, Uri address, FilePath outputPath, DownloadFileSettings settings)
at Cake.Common.Net.HttpAliases.DownloadFile(ICakeContext context, String address, FilePath outputPath)
at Submission#0.<.ctor>b__2()
at Cake.Core.CakeTaskBuilderExtensions.<>c__DisplayClass4_0.<Does>b__0(ICakeContext context) in E:\Code\cake\src\Cake.Core\CakeTaskBuilderExtensions.cs:line 104
at Cake.Core.ActionTask.Execute(ICakeContext context) in E:\Code\cake\src\Cake.Core\ActionTask.cs:line 52
at Cake.Core.DefaultExecutionStrategy.Execute(CakeTask task, ICakeContext context) in E:\Code\cake\src\Cake.Core\DefaultExecutionStrategy.cs:line 83
at Cake.Core.CakeEngine.ExecuteTask(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report) in E:\Code\cake\src\Cake.Core\CakeEngine.cs:line 245
at Cake.Core.CakeEngine.RunTarget(ICakeContext context, IExecutionStrategy strategy, String target) in E:\Code\cake\src\Cake.Core\CakeEngine.cs:line 152
at Cake.Scripting.BuildScriptHost.RunTarget(String target)
at Submission#0..ctor(Session session, Object& submissionResult)
at Submission#0.<Factory>(Session session)
at Roslyn.Scripting.CommonScriptEngine.Execute[T](String code, String path, DiagnosticBag diagnostics, Session session, Boolean isInteractive)
at Roslyn.Scripting.Session.Execute(String code)
at Cake.Scripting.Roslyn.Stable.DefaultRoslynScriptSession.Execute(Script script)
at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments) in E:\Code\cake\src\Cake.Core\Scripting\ScriptRunner.cs:line 201 at Cake.Commands.BuildCommand.Execute(CakeOptions options) at Cake.CakeApplication.Run(CakeOptions options) at Cake.Program.Main()---> (Inner Exception #0) System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The server committed a protocol violation. Section=ResponseStatusLine at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar) --- End of inner exception stack trace --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at Cake.Common.Net.HttpClientExtensions.<DownloadFileAsync>d__1.MoveNext()<---
### More Information
I suggest we set a user agent of "Cake" with the current version for every request. That should resolve the problem with endpoints that expect one, and it seems like the polite thing to do anyway. I'll submit a PR momentarily.
The text was updated successfully, but these errors were encountered:
What You Are Seeing?
Exception from sites that require a user agent header when calling
DownloadFile()
(the GitHub API is one such server that doesn't like agentless requests).What is Expected?
A successful file download.
What version of Cake are you using?
0.16.2
Are you running on a 32 or 64 bit system?
64
What environment are you running on? Windows? Linux? Mac?
Windows
Are you running on a CI Server? If so, which one?
No
How Did You Get This To Happen? (Steps to Reproduce)
Use the following code in a task (note that you must also have Octokit as an addin for this sample):
Output Log
Click to expand
I suggest we set a user agent of "Cake" with the current version for every request. That should resolve the problem with endpoints that expect one, and it seems like the polite thing to do anyway. I'll submit a PR momentarily.
The text was updated successfully, but these errors were encountered: