Overview
Features
Download
Documentation
Community
Add-Ons & Services

HTTPClientSession response transfer failure

Please post support and help requests here.

HTTPClientSession response transfer failure

Postby slimshader » 21 Jan 2013, 17:25

Hey,

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?
slimshader
 
Posts: 4
Joined: 10 Jan 2013, 13:40

Return to Support

Who is online

Users browsing this forum: No registered users and 5 guests