Hi momaison,
Let me explain a little bit how the HTTP response flow works with our library. I realize there should be documented better, eventually we will get up a tutorial or document describing this is more detail.
The task returned from http_client::request(...) is completed once the HTTP headers have arrived, it doesn't wait for body of the response to arrive as well. This allows for an opportunity for scenarios where streaming or dealing with large amounts of data can be handled. The task returned from the http_response::content_ready() and http_response::extract_*() methods will wait until the entire response body has arrived before completing.
In regards to errors and exceptions if an error occurs before the HTTP headers have completely arrived then an exception will be thrown out of a task from the http_client::request(...) function. All applications need to handle to properly handle exceptions in this case. If an error occurs after the HTTP headers have arrived it will result in an exception being throw from http_response::content_ready, the http_response::extract_* functions, or the response stream body. Exceptions at this point do not need to be properly observed and handled. We didn't want to make it a requirement that all requests must consume and read all response bodies. Please note if an error occurs and you actually are trying read the response body then you will see an exception.
So if you want or need to completely wait for a request to be completed with the entire response body completed you will need to wait or hook up a continuation to the task returned from http_response::content_ready() or the http_response::extract_* functions. Also FYI if you want to cancel a request you could do so using a cancellation_token that can be passed to the http_client::request(...) methods.
Does that help explain?
Steve
Let me explain a little bit how the HTTP response flow works with our library. I realize there should be documented better, eventually we will get up a tutorial or document describing this is more detail.
The task returned from http_client::request(...) is completed once the HTTP headers have arrived, it doesn't wait for body of the response to arrive as well. This allows for an opportunity for scenarios where streaming or dealing with large amounts of data can be handled. The task returned from the http_response::content_ready() and http_response::extract_*() methods will wait until the entire response body has arrived before completing.
In regards to errors and exceptions if an error occurs before the HTTP headers have completely arrived then an exception will be thrown out of a task from the http_client::request(...) function. All applications need to handle to properly handle exceptions in this case. If an error occurs after the HTTP headers have arrived it will result in an exception being throw from http_response::content_ready, the http_response::extract_* functions, or the response stream body. Exceptions at this point do not need to be properly observed and handled. We didn't want to make it a requirement that all requests must consume and read all response bodies. Please note if an error occurs and you actually are trying read the response body then you will see an exception.
So if you want or need to completely wait for a request to be completed with the entire response body completed you will need to wait or hook up a continuation to the task returned from http_response::content_ready() or the http_response::extract_* functions. Also FYI if you want to cancel a request you could do so using a cancellation_token that can be passed to the http_client::request(...) methods.
Does that help explain?
Steve