curl 7.21.7
When an easy handle is used to download an URI which has no Content-Length header (or equivalent) after downloading an URI which does, the value from the previous transfer is reused and returned by CURLINFO_CONTENT_LENGTH_DOWNLOAD. This is because the progress flags (used to determine whether such a header was received) are not reset between transfers. The quick fix I used is attached.
One-line fix
Thanks, this is truly a bug that has been around since the age of dawn!
If you can provide me with an email address as well, I'll have you credited in git as author of this patch! (by private email to me daniel at haxx.se is fine) you can also select not to and then I'll just credit you in the commit message by name instead.
Sure, why not? My email is rain at bluecherry dot net.
Thanks!
Thanks for the report, this problem is now fixed in the git repository.
To try it out, you either checkout/update your git clone: http://curl.haxx.se/source.html
or you try tomorrow's daily snapshot: http://curl.haxx.se/snapshots/