I am trying to add error handling for network/server failure when receiving HTTP response. Docs say:
n case a network or server failure happens while reading the response body from the returned stream, the stream state will change to bad or fail.
Problems is it seems that fail() returns true even for successful transfers when using StreamCopier:
- Code: Select all
std::istream& is = session.receiveResponse(response);
if (response.getStatus() == HTTPResponse::HTTP_OK)
{
Poco::StreamCopier::copyToString(is, body);
}
bool fail = is.fail(); // true
bool bad = is.bad();
bool eof = is.eof(); // true
if (fail)
{
// this throws even if all went fine
throw;
}
What is the correct way to check if transfer failed? Is there a way enable POCO exceptions for transfer failures?





