From fa78a0d811c2ee7d2be608722e38af643c6a036b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 12 Sep 2017 15:13:42 -0400 Subject: deal with box.com horrible infinite redirect behavior webdav: Checking if a non-existent file is present on Box.com triggered a bug in its webdav support that generates an infinite series of redirects. It seems to redirect foo to foo/ to foo/index.php to foo/index.php/index.php ... Why a webdav endpoint would behave this way who knows. Deal with such problems by assuming such behavior means the file is not present. Can't simply disable following redirects, because the webdav endpoint could legitimately be redirected to a new endpoint. So, when this happens 10 redirects have to be followed, before it gives up and assumes this means the file does not exist. This commit was supported by the NSF-funded DataLad project. --- Utility/Url.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Utility') diff --git a/Utility/Url.hs b/Utility/Url.hs index e1a21af5d..e6dcd3388 100644 --- a/Utility/Url.hs +++ b/Utility/Url.hs @@ -27,6 +27,7 @@ module Utility.Url ( downloadQuiet, parseURIRelaxed, matchStatusCodeException, + matchHttpExceptionContent, ) where import Common @@ -365,3 +366,9 @@ matchStatusCodeException want e@(StatusCodeException s _ _) | otherwise = Nothing matchStatusCodeException _ _ = Nothing #endif + +matchHttpExceptionContent :: (HttpExceptionContent -> Bool) -> HttpException -> Maybe HttpException +matchHttpExceptionContent want e@(HttpExceptionRequest _ hec) + | want hec = Just e + | otherwise = Nothing +matchHttpExceptionContent _ _ = Nothing -- cgit v1.2.3