From 04e26a911d64556074f4f0a8fa19fb762cc4348c Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Mon, 21 Jan 2019 22:24:09 +0000 Subject: [PATCH] In httpGetAP, if we got an unexpected Content-Type, specify it in error message --- src/Vervis/Handler/Inbox.hs | 2 +- src/Web/ActivityPub.hs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Vervis/Handler/Inbox.hs b/src/Vervis/Handler/Inbox.hs index 068ef1d..5908756 100644 --- a/src/Vervis/Handler/Inbox.hs +++ b/src/Vervis/Handler/Inbox.hs @@ -273,7 +273,7 @@ postOutboxR = do case eres of Left (APGetErrorHTTP e) -> setMessage $ toHtml $ "Failed to GET the recipient actor: " <> T.pack (displayException e) Left (APGetErrorJSON e) -> setMessage $ toHtml $ "Failed to parse recipient actor JSON: " <> T.pack (displayException e) - Left (APGetErrorContentType e) -> setMessage $ toHtml $ "Got unexpected Content-Type for actor JSON: " <> T.pack e + Left (APGetErrorContentType e) -> setMessage $ toHtml $ "Got unexpected Content-Type for actor JSON: " <> e Right response -> do let actor = getResponseBody response if actorId actor /= to diff --git a/src/Web/ActivityPub.hs b/src/Web/ActivityPub.hs index f775b56..930b764 100644 --- a/src/Web/ActivityPub.hs +++ b/src/Web/ActivityPub.hs @@ -254,7 +254,7 @@ provideAP v = do data APGetError = APGetErrorHTTP HttpException | APGetErrorJSON JSONException - | APGetErrorContentType String + | APGetErrorContentType Text deriving Show instance Exception APGetError @@ -285,7 +285,7 @@ httpGetAP manager uri = then case responseBody r of Left e -> Left $ APGetErrorJSON e Right v -> Right $ v <$ r - else Left $ APGetErrorContentType "Non-AP Content-Type" + else Left $ APGetErrorContentType $ "Non-AP Content-Type: " <> decodeUtf8 b _ -> Left $ APGetErrorContentType "Multiple Content-Type" -- Set method to POST, Set Content-Type, make HTTP signature, set response to throw on non-2xx