EndResponse() public method

Closes the HTTP context and responds to the calling client.
public EndResponse ( bool abort ) : void
abort bool if set to true, the connection is aborted without responding.
return void
示例#1
0
        /// <summary>
        ///     Processes the incoming HTTP request asynchronously.
        /// </summary>
        /// <param name="asyncResult">The asynchronous result.</param>
        private async void ProcessAsyncRequest()
        {

            if (_listener == null)
            {
                return;
            }

            try
            {
                // Gets the HTTP context for the request
                var context = await _listener.GetContextAsync();
                WaitForConnections();

                // Create a new StumpsHttpContext
                var stumpsContext = new StumpsHttpContext(context);

                if (this.RequestReceived != null)
                {
                    this.RequestReceived(this, new StumpsContextEventArgs(stumpsContext));
                }

                // Process the request through the HTTP handler
                var processResult = await _handler.ProcessRequest(stumpsContext);

                if (this.RequestProcessed != null)
                {
                    this.RequestProcessed(this, new StumpsContextEventArgs(stumpsContext));
                }

                var abortConnection = processResult == ProcessHandlerResult.DropConnection;

                // End the request
                stumpsContext.EndResponse(abortConnection);

                if (this.RequestFinished != null)
                {
                    this.RequestFinished(this, new StumpsContextEventArgs(stumpsContext));
                }

            }
            catch (HttpListenerException)
            {
            }
            catch (InvalidOperationException)
            {
            }

        }