First version
Fix EOF detection

    Well sort of.
    Makes assumption that server uses "Content length:" header.
    This allows us to detect when there is no more data.
Limit scope of underflow() lock

    Prevent potential deadlock if curl is using the same thread.