Description
Hi!
We have C++ REST client application that uses cpprestsdk. We have the scenario when we get unhandled std::logic_error exception (uninitialized stream object).
The mentioned scenario is:
- client sends to the server PUT request with the meaningful body
- server replies with UNAUTHORIZED error if the request's access token is expired
- client handles this error, requests the new access token using another HTTP requests
- client tries to resend the former PUT request with updated access token (Authorization header)
- cpprestsdk code throws std::logic_error exception
I managed to debug the case under Windows. I see that after the first attempt to send the request we have empty body (empty 'm_inStream: concurrency::streams::istream' field).
The stream is reset here:
void request_context::complete_headers()
{
// We have already read (and transmitted) the request body. Should we explicitly close the stream?
// Well, there are test cases that assumes that the istream is valid when t receives the response!
// For now, we will drop our reference which will close the stream if the user doesn't have one.
m_request.set_body(Concurrency::streams::istream());
m_request_completion.set(m_response);
}
The main question is whether we actually have to reset the body after request has been send? I will try to comment the string with the body clearing and see the result.
Thanks!