From 7a419e26cee31767c111ed15e91043901a4b6c35 Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Sun, 20 Mar 2022 22:26:45 -0500 Subject: [PATCH] fix: Prevent redirects I observed that when the user specifies an invalid URL to their Radarr or Sonarr instance (such as forgetting to use the Base URL), it attempts to redirect by returning HTTP 300. This is now prevented and a warning is printed to output. --- CHANGELOG.md | 5 +++++ src/TrashLib/Extensions/FlurlLogging.cs | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75856027..07d786bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Do not follow HTTP redirects and instead issue a warning to the user that they are potentially + using the wrong URL. + ## [1.8.2] - 2022-03-06 ### Fixed diff --git a/src/TrashLib/Extensions/FlurlLogging.cs b/src/TrashLib/Extensions/FlurlLogging.cs index ee15f10d..92065abb 100644 --- a/src/TrashLib/Extensions/FlurlLogging.cs +++ b/src/TrashLib/Extensions/FlurlLogging.cs @@ -22,5 +22,13 @@ public static class FlurlLogging var url = urlInterceptor(call.Request.Url.Clone()); log.Debug("HTTP Response {Status} from {Url}", statusCode, url); }; + + settings.OnRedirect = call => + { + log.Warning("HTTP Redirect received; this indicates a problem with your URL and/or reverse proxy: {Url}", + call.Redirect.Url); + + call.Redirect.Follow = false; + }; } }