private async Task HandleIncomingConnections()

in DarabonbaUnitTests/Utils/StreamUtilsTest.cs [34:64]


        private async Task HandleIncomingConnections(CancellationToken cancellationToken)
        {
            while (!_cancellationTokenSource.IsCancellationRequested)
            {
                try
                {
                    var context = await _httpListener.GetContextAsync().ConfigureAwait(false);

                    if (context.Request.Url?.AbsolutePath == "/sse")
                    {
                        HandleSseResponse(context.Response);
                    }
                    else if (context.Request.Url?.AbsolutePath == "/sse_with_no_spaces")
                    {
                        HandleSseWithNoSpacesResponse(context.Response);
                    }
                    else if (context.Request.Url?.AbsolutePath == "/sse_invalid_retry")
                    {
                        HandleSseWithInvalidRetryResponse(context.Response);
                    }
                    else if (context.Request.Url?.AbsolutePath == "/sse_with_data_divided")
                    {
                        HandleSseWithDataDividedResponse(context.Response);
                    }
                }
                catch (HttpListenerException) when (cancellationToken.IsCancellationRequested)
                {
                    throw new HttpListenerException();
                }
            }
        }