Exemple #1
0
        protected override IEnumerable <Envelope> CreateNewItemsFromContext(HttpListenerContext context)
        {
            try
            {
                var request = context.Request;
                var content = request.GetContent();

                if (!string.IsNullOrWhiteSpace(request.Headers["Content-Encoding"]) &&
                    string.Equals("gzip", request.Headers["Content-Encoding"],
                                  StringComparison.InvariantCultureIgnoreCase))
                {
                    content = Decompress(content);
                }

                Trace.WriteLine("=>");
                Trace.WriteLine("Item received: " + content);
                Trace.WriteLine("<=");

                return(TelemetryItemFactory.GetTelemetryItems(content));
            }
            finally
            {
                context.Response.Close();
            }
        }
        protected override IEnumerable <Envelope> CreateNewItemsFromContext(HttpListenerContext context)
        {
            try
            {
                var request = context.Request;
                var content = request.GetContent();

                if (!string.IsNullOrWhiteSpace(request.Headers["Content-Encoding"]) &&
                    string.Equals("gzip", request.Headers["Content-Encoding"],
                                  StringComparison.InvariantCultureIgnoreCase))
                {
                    content = Decompress(content);
                }

                Trace.WriteLine("=>");
                Trace.WriteLine("Item received: " + content);
                Trace.WriteLine("<=");

                // Validating each package takes too much time, check only first one that have dependency data
                if (this.validatedPackages == 0 && (content.Contains("Request") || content.Contains("Exception")))
                {
                    try
                    {
                        this.ValidateItems(content);
                        ++this.validatedPackages;
                    }
                    catch (TaskCanceledException)
                    { }
                }

                return(TelemetryItemFactory.GetTelemetryItems(content));
            }
            finally
            {
                context.Response.Close();
            }
        }