/// <summary> /// If there is a stream handler registered that can handle the /// request, then fine. If the request is not matched, do /// nothing. /// Note: The selection is case-insensitive /// </summary> private bool FindStreamHandler(OSHttpRequest request, OSHttpResponse response) { RequestData rdata = new RequestData(request, response, String.Empty); string bestMatch = String.Empty; string path = String.Format("{0}:{1}", rdata.method, rdata.path).ToLower(); Rest.Log.DebugFormat("{0} Checking for stream handler for <{1}>", MsgId, path); if (!IsEnabled) { return(false); } foreach (string pattern in streamHandlers.Keys) { if (path.StartsWith(pattern)) { if (pattern.Length > bestMatch.Length) { bestMatch = pattern; } } } // Handle using the best match available if (bestMatch.Length > 0) { Rest.Log.DebugFormat("{0} Stream-based handler matched with <{1}>", MsgId, bestMatch); RestStreamHandler handler = streamHandlers[bestMatch]; rdata.buffer = handler.Handle(rdata.path, rdata.request.InputStream, rdata.request, rdata.response); rdata.AddHeader(rdata.response.ContentType, handler.ContentType); rdata.Respond("FindStreamHandler Completion"); } return(rdata.handled); }