From 1b9ccc319f8235a1205a7e8a8b508cf81f965de6 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Thu, 3 Aug 2017 16:49:54 +0200 Subject: [PATCH] Fixed: TLS issue for OSX. --- .../Http/Dispatchers/ManagedHttpDispatcher.cs | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs b/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs index 8fd02d4e8..4a7269468 100644 --- a/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs +++ b/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs @@ -47,19 +47,19 @@ namespace NzbDrone.Common.Http.Dispatchers AddRequestHeaders(webRequest, request.Headers); } - if (request.ContentData != null) - { - webRequest.ContentLength = request.ContentData.Length; - using (var writeStream = webRequest.GetRequestStream()) - { - writeStream.Write(request.ContentData, 0, request.ContentData.Length); - } - } - HttpWebResponse httpWebResponse; try { + if (request.ContentData != null) + { + webRequest.ContentLength = request.ContentData.Length; + using (var writeStream = webRequest.GetRequestStream()) + { + writeStream.Write(request.ContentData, 0, request.ContentData.Length); + } + } + httpWebResponse = (HttpWebResponse)webRequest.GetResponse(); } catch (WebException e) @@ -78,13 +78,17 @@ namespace NzbDrone.Common.Http.Dispatchers { throw new WebException($"DNS Name Resolution Failure: '{webRequest.RequestUri.Host}'", e.Status); } + else if (e.ToString().Contains("TLS Support not")) + { + throw new TlsFailureException(webRequest, e); + } else if (e.ToString().Contains("The authentication or decryption has failed.")) { throw new TlsFailureException(webRequest, e); } else if (OsInfo.IsNotWindows) { - throw new WebException($"{e.Message}: '{webRequest.RequestUri}'", e.Status); + throw new WebException($"{e.Message}: '{webRequest.RequestUri}'", e, e.Status, e.Response); } else {