Can I handle streams with http_client?

Aug 14, 2014 at 4:57 PM
By "streams" I mean something like mjpeg.
Actualy I have tied to write some code:
http_client client(host);
uri_builder builder(L"/"+path + m_File);
container_buffer<std::string> buffer;

client.request(methods::GET, builder.to_string(), cancellationTokenSource.get_token()).then([this, buffer](http_response response)
    OutputDebugString((L"Received response status code: " + NumToStr(response.status_code()) + L"\n").c_str());
}).then([this, buffer](/*streams::istream stream*/task<void>prevTask)
    try {
    catch (Platform::Exception^ ex)
    catch (std::exception ex)
        string message(ex.what());
And it work perfect with static images, but when I try to feed mjpeg link - I got "Unknown exception". So question is: Does current implementaion of SDK supports such cases?
Aug 14, 2014 at 5:22 PM
Sorry, I think I rushed. Guess this exception was raised because of lack of credentials
Aug 14, 2014 at 5:38 PM
Hi Daemonolog,

Exception authentication issues aside I assume what you are referring to is getting the HTTP response body through a stream as the chunks come across the network. Yes this is possible with the C++ Rest SDK. The task returned from http_client::request is signaled once all the HTTP headers have arrived. You can then call http_response::body() to get access to the underlying stream for the response body. I believe this should be what you are looking for.

Aug 14, 2014 at 6:19 PM
Yes, this is what I looked for. Thank you