/// <summary> /// Occurs when a request is received /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void OnRequestReceived(object sender, HttpRequestCancelEventArgs e) { // dispatch the request out to be handled if (_dispatcher != null) { _dispatcher.DispatchRequest(sender, ref e); } else { Debug.WriteLine(string.Format("Received a message, however there is no dispatcher available to handle the message for connection '{0}'.", _id.ToString())); } // did someone cancel the request? if (e.Cancel) { return; // do not send a response, some will have done this manually } /* * IMPORTANT!!! - We are providing a mechanism to override the default HTTP/1.1 specification's behaviour. * The specs state explicitly under all conditions a response must be sent to a request. We have certain scenarious where * we only need to send a request, no further processing is required as to the result of the request by the user-agent, so * the 'Reponse-Needed' header can be included to prevent the 'Server' from responding to the request. * */ if (e.Request.ResponseNeeded) { // if there is a response prepared let's send it now HttpRequest request = e.Request; HttpResponse response = e.Response; // send a response to the request this.SendResponseToRequest(ref request, ref response); } }