Skip to content

Commit

Permalink
fix: ignore body of responses to head requests as per spec
Browse files Browse the repository at this point in the history
  • Loading branch information
gkleen committed Apr 2, 2024
1 parent 45e88d8 commit 6aca487
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Network/Minio/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ httpLbs req mgr = do
resp <- either throwIO return respE
unless (isSuccessStatus $ NC.responseStatus resp) $
case contentTypeMay resp of
Just "application/xml" -> do
Just "application/xml" | expectBody -> do
sErr <- parseErrResponse $ NC.responseBody resp
throwIO sErr
Just "application/json" -> do
Just "application/json" | expectBody -> do
sErr <- parseErrResponseJSON $ NC.responseBody resp
throwIO sErr
_ ->
Expand All @@ -204,6 +204,7 @@ httpLbs req mgr = do
contentTypeMay resp =
lookupHeader Hdr.hContentType $
NC.responseHeaders resp
expectBody = NC.method req /= HT.methodHead

http ::
(MonadUnliftIO m, R.MonadResource m) =>
Expand All @@ -215,7 +216,7 @@ http req mgr = do
resp <- either throwIO return respE
unless (isSuccessStatus $ NC.responseStatus resp) $
case contentTypeMay resp of
Just "application/xml" -> do
Just "application/xml" | expectBody -> do
respBody <- C.connect (NC.responseBody resp) CB.sinkLbs
sErr <- parseErrResponse respBody
throwIO sErr
Expand All @@ -235,6 +236,7 @@ http req mgr = do
contentTypeMay resp =
lookupHeader Hdr.hContentType $
NC.responseHeaders resp
expectBody = NC.method req /= HT.methodHead

-- Similar to mapConcurrently but limits the number of threads that
-- can run using a quantity semaphore.
Expand Down

0 comments on commit 6aca487

Please sign in to comment.