diff -r 20cccc7c26ee -r 5e4855a592ee BLIP/BLIPConnection.m --- a/BLIP/BLIPConnection.m Sun May 24 15:03:39 2009 -0700 +++ b/BLIP/BLIPConnection.m Fri Jul 24 14:06:28 2009 -0700 @@ -69,13 +69,14 @@ } -- (void) _dispatchMetaRequest: (BLIPRequest*)request +- (BOOL) _dispatchMetaRequest: (BLIPRequest*)request { NSString* profile = request.profile; - if( [profile isEqualToString: kBLIPProfile_Bye] ) + if( [profile isEqualToString: kBLIPProfile_Bye] ) { [self _handleCloseRequest: request]; - else - [request respondWithErrorCode: kBLIPError_NotFound message: @"Unknown meta profile"]; + return YES; + } + return NO; } @@ -83,11 +84,19 @@ { LogTo(BLIP,@"Received all of %@",request.descriptionWithProperties); @try{ + BOOL handled; if( request._flags & kBLIP_Meta ) - [self _dispatchMetaRequest: request]; - else if( ! [self.dispatcher dispatchMessage: request] ) - [self tellDelegate: @selector(connection:receivedRequest:) withObject: request]; - if( ! request.noReply && ! request.repliedTo ) { + handled =[self _dispatchMetaRequest: request]; + else { + handled = [self.dispatcher dispatchMessage: request]; + if (!handled && [_delegate respondsToSelector: @selector(connection:receivedRequest:)]) + handled = [_delegate connection: self receivedRequest: request]; + } + + if (!handled) { + LogTo(BLIP,@"No handler found for incoming %@",request); + [request respondWithErrorCode: kBLIPError_NotFound message: @"No handler was found"]; + } else if( ! request.noReply && ! request.repliedTo ) { LogTo(BLIP,@"Returning default empty response to %@",request); [request respondWithData: nil contentType: nil]; }