1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-29 12:24:52 +09:00

In httpGetAP, if we got an unexpected Content-Type, specify it in error message

This commit is contained in:
fr33domlover 2019-01-21 22:24:09 +00:00
parent 2a68bb560b
commit 04e26a911d
2 changed files with 3 additions and 3 deletions

View file

@ -273,7 +273,7 @@ postOutboxR = do
case eres of case eres of
Left (APGetErrorHTTP e) -> setMessage $ toHtml $ "Failed to GET the recipient actor: " <> T.pack (displayException e) 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 (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 Right response -> do
let actor = getResponseBody response let actor = getResponseBody response
if actorId actor /= to if actorId actor /= to

View file

@ -254,7 +254,7 @@ provideAP v = do
data APGetError data APGetError
= APGetErrorHTTP HttpException = APGetErrorHTTP HttpException
| APGetErrorJSON JSONException | APGetErrorJSON JSONException
| APGetErrorContentType String | APGetErrorContentType Text
deriving Show deriving Show
instance Exception APGetError instance Exception APGetError
@ -285,7 +285,7 @@ httpGetAP manager uri =
then case responseBody r of then case responseBody r of
Left e -> Left $ APGetErrorJSON e Left e -> Left $ APGetErrorJSON e
Right v -> Right $ v <$ r 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" _ -> Left $ APGetErrorContentType "Multiple Content-Type"
-- Set method to POST, Set Content-Type, make HTTP signature, set response to throw on non-2xx -- Set method to POST, Set Content-Type, make HTTP signature, set response to throw on non-2xx