From 30e26b0d9663dcf658a569d47a4c4a1f6a3e6a3c Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Thu, 2 Oct 2014 22:29:25 +0200 Subject: [PATCH] improved HTTPClientSession error handling for network errors handling during sending the request --- Net/include/Poco/Net/HTTPSession.h | 5 ++++- Net/src/HTTPClientSession.cpp | 2 ++ Net/src/HTTPSession.cpp | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Net/include/Poco/Net/HTTPSession.h b/Net/include/Poco/Net/HTTPSession.h index 6df4eefa1..0b01c2ca8 100644 --- a/Net/include/Poco/Net/HTTPSession.h +++ b/Net/include/Poco/Net/HTTPSession.h @@ -164,7 +164,10 @@ protected: void setException(const Poco::Exception& exc); /// Stores a clone of the exception. - + + void clearException(); + /// Clears the stored exception. + private: enum { diff --git a/Net/src/HTTPClientSession.cpp b/Net/src/HTTPClientSession.cpp index d9ebe481c..5e4d28d07 100644 --- a/Net/src/HTTPClientSession.cpp +++ b/Net/src/HTTPClientSession.cpp @@ -163,6 +163,7 @@ void HTTPClientSession::setKeepAliveTimeout(const Poco::Timespan& timeout) std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request) { + clearException(); _pResponseStream = 0; bool keepAlive = getKeepAlive(); @@ -229,6 +230,7 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request) std::istream& HTTPClientSession::receiveResponse(HTTPResponse& response) { _pRequestStream = 0; + if (networkException()) networkException()->rethrow(); do { diff --git a/Net/src/HTTPSession.cpp b/Net/src/HTTPSession.cpp index 640af20f6..ba1dd6c1f 100644 --- a/Net/src/HTTPSession.cpp +++ b/Net/src/HTTPSession.cpp @@ -210,6 +210,13 @@ void HTTPSession::setException(const Poco::Exception& exc) } +void HTTPSession::clearException() +{ + delete _pException; + _pException = 0; +} + + StreamSocket HTTPSession::detachSocket() { StreamSocket oldSocket(_socket);