Index: src/OFHTTPServer.h ================================================================== --- src/OFHTTPServer.h +++ src/OFHTTPServer.h @@ -34,10 +34,26 @@ * @param request The request the HTTP server received * @return The reply the HTTP server should send to the client */ - (OFHTTPRequestReply*)server: (OFHTTPServer*)server didReceiveRequest: (OFHTTPRequest*)request; + +#ifdef OF_HAVE_OPTIONAL_PROTOCOLS +@optional +#endif +/*! + * @brief This method is called when the HTTP server's listening socket + * encountered an exception. + * + * @param exception The exception that occurred on the HTTP server's listening + * socket + * @return Whether to continue listening. If you return NO, existing connections + * will still be handled and you can start accepting new connections + * again by calling @ref start again. + */ +- (BOOL)server: (OFHTTPServer*)server + didReceiveExceptionOnListeningSocket: (OFException*)e; @end /*! * @brief A class for creating a simple HTTP server inside of applications. */ @@ -134,5 +150,8 @@ - (BOOL)OF_socket: (OFTCPSocket*)socket didAcceptSocket: (OFTCPSocket*)clientSocket exception: (OFException*)exception; @end + +@interface OFObject (OFHTTPServerDelegate) +@end Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -642,12 +642,18 @@ didAcceptSocket: (OFTCPSocket*)clientSocket exception: (OFException*)exception { OFHTTPServer_Connection *connection; - if (exception != nil) + if (exception != nil) { + if ([delegate respondsToSelector: + @selector(server:didReceiveExceptionOnListeningSocket:)]) + return [delegate server: self + didReceiveExceptionOnListeningSocket: exception]; + return NO; + } connection = [[[OFHTTPServer_Connection alloc] initWithSocket: clientSocket server: self] autorelease];