-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
I had this problem during HTTPS session setup and failed reauthentication after sending the URL (the request has been processed, the HTTPS server asked for credentials using the reauthenticate request and that failed - the Poco client supplied wrong certificate). The exception thrown from SSL layer got swallowed, the NoMessageException was thrown instead.
The method HTTPClientSession::receiveResponse creates HTTPHeaderInputStream to read the header. The HTTPResponse::read method is called with the input stream as an argument. If there is an exception on the very first istream::get() call (which calls HTTPSession::get()), the exception is remembered inside HTTPClientSession (setException call) and the istream swallows the exception - it sets the fail bit. The method HTTPResponse::read gets eof instead of exception and throws NoMessageException without checking the stored exception.
I think that the solution for the similar problem in #454 is conceptually wrong - it changes the exception behaviour on the constructor argument. Better would be to move the exception behaviour setting to the place where it is really needed and do not force the library's default (which is to swallow exceptions). Good place is the one where the particular input stream is created, used and destroyed - if the input stream is created to be returned, it shall not change the exception handling.
Anyway, the fix might be similar to the one committed in #454, or just to add handling of NoMessageException in the same way as MessageException in HTTPClientSession::receiveResponse.