Use chunked encoding for upload streams of unknown length; fix segfault that occured
when the response was ready before the request was done.