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)
bool fail = is.fail(); // true
bool bad = is.bad();
bool eof = is.eof(); // true
// this throws even if all went fine
What is the correct way to check if transfer failed? Is there a way enable POCO exceptions for transfer failures?