#176 propagate exceptions in HTTP back to application

Undecided
open
nobody
None
1
2012-12-20
2012-12-20
Aviad Rozenhek
No

when using Poco::Net::HTTPServer, malformed requests do not propagate into the application's RequestHandler. but the application doesn't get a chance to see these malformed requests or the exceptions that they caused. this prevents an application to log malformed requests and/or the IP that generated them.

my suggestion is that HTTPServer will accept an additional [optional] argument of the following type

class IHTTPServerErrorHandler
{
virtual ~IHTTPServerErrorHandler() {}
virtual reportSessionError(Poco::Net::NoMessageException&, HTTPServerSession&);
virtual reportSessionError(Poco::Net::MessageException&, HTTPServerSession&);
virtual reportRequestError(Poco::Exception&, HTTPServerSession&, HTTPServerRequest&, HTTPServerResponse&);
};

the application could implement this interface, (much like it implements the request handler factory), and pass an instance of this interface to the HTTPServer, which would pass it to HTTPServerConnectionFactory and ultimately to HTTPServerConnection.

then in HTTPServerConnection::run(), calls to this interface will be made from every catch() clause.

Discussion