snoyberg / http-enumerator

HTTP client package with enumerator interface and HTTPS support.
27 stars 9 forks source link

Fix rawBody/transfer-encoding-chunked logic. #38

Closed erikd closed 13 years ago

erikd commented 13 years ago

The problem I described in issue #37 was that for the case where there the transfer encoding is not chunked it would still end up using a chunked enumeratee due to the Nothing in:

         case mcl >>= readMay . S8.unpack of
               Just len -> (takeLBS len =$)
               Nothing -> (chunkedTerminator =$)

With this patch, we only use chunkedEnumeratee and chunkedTerminator when the transfer encoding is in fact chunked. Otherwise we either use the provided content-length or id (because if is no content-length provided the server should close the connection at the end of the transfer).

snoyberg commented 13 years ago

Do you believe this code is now ready to be released?

erikd commented 13 years ago

With this patch it now seems to be working for everything I've tested. Pretty sure there are still other corner cases to be found :-).

snoyberg commented 13 years ago

OK, new version on hackage. Let me know if something goes wrong ;)

erikd commented 13 years ago

Thanks!