CurlFollowLocation True,
-- Give it a little time...
- CurlTimeout 45,
-
- -- For debugging.
- CurlVerbose True ]
+ CurlTimeout 45 ]
make_cookie_jar :: IO FilePath
-- | Log in using curl. Store the resulting session cookies in the
--- supplied file.Warning: This returns an error if the function
--- fails!
-log_in :: FilePath -> String -> String -> IO (Maybe String)
+-- supplied file.
+log_in :: FilePath -> String -> String -> IO (Either String String)
log_in cookie_jar username password =
withCurlDo $ do
-- Create a curl instance.
return $
case code of
- CurlOK -> Nothing
- error_code -> Just $ "HTTP Error: " ++ (show error_code)
+ CurlOK -> Right (respBody resp)
+ error_code -> Left $ "HTTP Error: " ++ (show error_code)
-- If an error occurred, we want to dump as much information as
-- possible. If this becomes a problem, we can use respGetInfo to
-- query the response object for more information