]> gitweb.michael.orlitzky.com - dead/lwn-epub.git/blobdiff - src/LWN/HTTP.hs
Final cleanups to get the download working.
[dead/lwn-epub.git] / src / LWN / HTTP.hs
index 1b6bcfd3c966a060ea326a06245f67811f66ba9a..71058dc67040b69da700e2744fe1daa796ae3607 100644 (file)
@@ -48,10 +48,7 @@ default_curl_opts =
     CurlFollowLocation True,
 
     -- Give it a little time...
-    CurlTimeout 45,
-
-    -- For debugging.
-    CurlVerbose True ]
+    CurlTimeout 45 ]
 
 
 make_cookie_jar :: IO FilePath
@@ -93,9 +90,8 @@ get_page cookie_file url =
 
 
 -- | 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.
@@ -111,8 +107,8 @@ log_in cookie_jar username password =
 
     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