Skip to content

Commit d05ecb9

Browse files
committed
dont HEAD before GET
1 parent 1951a01 commit d05ecb9

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

src/File.purs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ instance (MonadAff m, MonadError Error m, LoadFile m) => LoadFile (StateT s m) w
3535
instance LoadFile Aff where
3636
loadFileFromPath (File path) = do
3737
result <- runExceptT $ do
38-
_ × path' <- ExceptT $ liftAff $ checkPath
38+
resp × path' <- ExceptT $ liftAff $ requestPath
3939
when debug.logging $ liftAff $ log ("loadFileFromPath: resolved path: " <> path')
40-
contents <- ExceptT $ liftAff $ request (defaultRequest { url = path', method = Left GET, responseFormat = string })
41-
pure contents.body
40+
pure resp.body
4241
pure $ either (const Nothing) Just result
4342
where
44-
checkPath :: Aff (Either A.Error (Response String × String))
45-
checkPath = do
46-
resp <- request (defaultRequest { url = path, method = Left HEAD, responseFormat = string })
43+
requestPath :: Aff (Either A.Error (Response String × String))
44+
requestPath = do
45+
resp <- request (defaultRequest { url = path, method = Left GET, responseFormat = string })
4746
pure case resp of
4847
Right resp' | resp'.status == StatusCode 200 -> Right (resp' × path)
4948
Right _ -> Left A.RequestFailedError

0 commit comments

Comments
 (0)