[Haskell-cafe] Network.Curl cookie jar madness

Michael Orlitzky michael at orlitzky.com
Sun Aug 19 02:52:00 CEST 2012


I'm one bug away from a working program and need some help. I wrote a
little utility that logs into LWN.net, retrieves an article, and creates
an epub out of it. Full code here:

  git clone http://michael.orlitzky.com/git/lwn-epub.git

This is the code that gets the login cookie:

  cj <- make_cookie_jar
  li_result <- log_in cj uname pword

  case li_result of
    Left err -> do
      let msg = "Failed to log in. " ++ err
      hPutStrLn stderr msg
    Right response_body -> do
      hPutStrLn stderr response_body

  return $ cfg { C.cookie_jar = Just cj }

Curl is making the request, but if I remove the (hPutStrLn stderr
response_body), it doesn't work! What's even more insane is, this works:

  hPutStrLn stderr response_body

and this doesn't:

  hPutStrLn stdout response_body

whaaaaaaatttttttt? I really don't want to dump the response body to
stderr, but I can't even begin to imagine what's going on here. Has
anyone got Network.Curl working with a cookie jar?

For anyone with an LWN account: you can set,

  username = foo
  password = bar

in ~/.lwn-epub/lwn-epub.conf and attempt to run with,

  lwn-epub -o current.epub current/bigpage



More information about the Haskell-Cafe mailing list