snoyberg/http-conduit — pull request #99 by litherum (2013-01-31 19:37:32+00:00)
Title: CookieJar logic lives in httpRaw

@exbb2

The purpose of this is to not overload the meaning of
'redirectCount'. Cookie handling should be consistent regardless
of redirections.

Please take a moment to review this patch. I'm not sure you'll agree with some of the design decision that I've made. Specifically, if CookieJars live in requests and responses, getRedirectedRequest needs to copy the cookie jar out of the Response and into the new Request, which means that getRedirectedRequest needs to take a cookie jar as well as the ResponseHeaders. However, if we want to support the use case of our users re-implementing their own redirection following logic on top of the 'http' function, they have to be able to call getRedirectedRequest with the fields that a StatusCodeException contains (see the comment above getRedirectedRequest). Therefore, quite a few other functions need to take a CookieJar as an extra argument.

It's a bad idea to simply change getRedirectedRequest to take the entire response, because then the StatusCodeException has to have a Response field, which means that the 'checkStatus' function has to take a Response, which means that the Request type has to be parameterized over another argument (the 'body' type argument in the type 'Response body').

Is my logic wrong? Is there a better way to support this use case?