public async Task StreamWinderPerformanceTest()
        {
            var source     = new CancellationTokenSource();
            var testStream = new InfiniteStream(TweetSamples.GetBinalyStreamSamples(), source.Token);
            var handler    = new PseudoStreamHandler();
            var received   = 0;

            source.CancelAfter(TimeSpan.FromSeconds(10));
            var receiveTask = StreamWinder.Run(testStream, content =>
            {
                UserStreamParser.ParseStreamLine(content, handler);
                received++;
            }, Timeout.InfiniteTimeSpan, source.Token);

            try
            {
                await receiveTask;
            }
            catch (OperationCanceledException)
            {
                // this is expected.
            }
            System.Diagnostics.Debug.WriteLine(received);
            // i promise myself the cadena engine can handle > 10K events per second.
            Debug.WriteLine("received: {0}", received);
            Debug.WriteLine("handler: statuses: {0} / events: {1}", handler.ReceivedStatuses, handler.ReceivedEvents);
            // Assert.IsTrue(received > 10000 * 10);
        }
示例#2
0
        public async Task CanSetContentLengthOverMaxInt()
        {
            long contentLength = 0;

            using TestServer testServer = new TestServer(
                      context =>
            {
                contentLength = context.Request.ContentLength.Value;
                context.Abort();
            });

            var     transport = GetTransport();
            Request request   = transport.CreateRequest();

            request.Method = RequestMethod.Post;
            request.Uri.Reset(testServer.Address);
            var infiniteStream = new InfiniteStream();

            request.Content = RequestContent.Create(infiniteStream);

            try
            {
                await ExecuteRequest(request, transport);
            }
            catch (Exception)
            {
                // Sending the request would fail because of length mismatch
            }

            // InfiniteStream has a length of long.MaxValue check that it got sent correctly
            Assert.AreEqual(infiniteStream.Length, contentLength);
            Assert.Greater(infiniteStream.Length, int.MaxValue);
        }
 public async Task StreamWinderPerformanceTest()
 {
     var source = new CancellationTokenSource();
     var testStream = new InfiniteStream(TweetSamples.GetBinalyStreamSamples(), source.Token);
     var handler = new PseudoStreamHandler();
     var received = 0;
     source.CancelAfter(TimeSpan.FromSeconds(10));
     var receiveTask = StreamWinder.Run(testStream, content =>
     {
         UserStreamParser.ParseStreamLine(content, handler);
         received++;
     }, Timeout.InfiniteTimeSpan, source.Token);
     try
     {
         await receiveTask;
     }
     catch (OperationCanceledException)
     {
         // this is expected.
     }
     System.Diagnostics.Debug.WriteLine(received);
     // i promise myself the cadena engine can handle > 10K events per second.
     Debug.WriteLine("received: {0}", received);
     Debug.WriteLine("handler: statuses: {0} / events: {1}", handler.ReceivedStatuses, handler.ReceivedEvents);
     // Assert.IsTrue(received > 10000 * 10);
 }
示例#4
0
        public async Task <ActionResult> IndexPhp()
        {
            var remoteIpAddress = Request?.HttpContext?.Connection?.RemoteIpAddress;

            _logger.LogInformation("Remote Ip Address {0}, {1}", remoteIpAddress, remoteIpAddress?.MapToIPv4());
            var infiniteStream = new InfiniteStream();

            return(File(infiniteStream, "text/html"));
        }