[Haskell-cafe] Network.Curl cookie jar madness

Michael Orlitzky michael at orlitzky.com
Sun Aug 19 03:50:33 CEST 2012


On 08/18/2012 09:00 PM, Iustin Pop wrote:
> On Sat, Aug 18, 2012 at 08:52:00PM -0400, Michael Orlitzky wrote:
>>
>> 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?
> 
> Is this perchance due to laziness? And the fact that stderr is not
> buffered by default, so all output is forced right then (forcing the
> evaluation), whereas stdout is buffered, so the output might only be
> made later (or even after you to an hFlush).
> 
> I'd try to make sure that response_body is fully evaluated before
> returning from the function.
> 
> Or I might be totally wrong, in which case sorry :)
> 

I thought so at first, but I've tried every trick I know to avoid it. If
I add an hFlush to the stdout version, it still fails. If I deepseq the
response_body (it's just a string, after all), it still fails.

In the case statement, we've already made the request and received a
response (the Left/Right is based on the response code). I'm thinking
the cookie jar should be full at that point whether or not I use the
response body.



More information about the Haskell-Cafe mailing list