Ejemplo n.º 1
0
        /// <summary>
        /// Scrubs the HTTP messages.
        /// </summary>
        /// <param name="payloadBundle">The payload bundle.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        private bool ScrubHttpMessages(PayloadBundle payloadBundle)
        {
            Payload payload = payloadBundle.GetPayload();

            DTOs.Request request = payload.Data.Request;
            if (request?.PostBody is string requestBody)
            {
                if (request.Headers.TryGetValue("Content-Type", out string contentTypeHeader))
                {
                    request.PostBody =
                        this.ScrubHttpMessageBodyContentString(
                            requestBody,
                            contentTypeHeader,
                            this._payloadScrubber.ScrubMask,
                            this._payloadScrubber.PayloadFieldNames,
                            this._payloadScrubber.HttpRequestBodyPaths);
                }
            }

            DTOs.Response response = payload.Data.Response;
            if (response?.Body is string responseBody)
            {
                if (response.Headers.TryGetValue("Content-Type", out string contentTypeHeader))
                {
                    response.Body =
                        this.ScrubHttpMessageBodyContentString(
                            responseBody,
                            contentTypeHeader,
                            this._payloadScrubber.ScrubMask,
                            this._payloadScrubber.PayloadFieldNames,
                            this._payloadScrubber.HttpResponseBodyPaths);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Data" /> class.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="body">The body.</param>
        /// <param name="custom">The custom.</param>
        /// <param name="request">The request.</param>
        public Data(IRollbarConfig config, Body body, IDictionary <string, object> custom = null, Request request = null)
        {
            Assumption.AssertNotNull(config, nameof(config));
            Assumption.AssertNotNull(body, nameof(body));

            // snap config values:
            this.Environment = config.Environment;
            this.Level       = config.LogLevel;
            this.Person      = config.Person;
            this.Server      = config.Server;

            // set explicit values:
            this.Body    = body;
            this.Request = request;
            this.Custom  = custom;

            // set calculated values:
            this.Platform  = Data.DefaultPlatform;
            this.Framework = Data.DefaultFrameworkValue;
            this.Language  = Data.DefaultLanguage;
            this.Notifier  = new Dictionary <string, string>
            {
                { "name", "Rollbar.NET" },
                { "version", Data.NotifierAssemblyVersion },
            };
            this.GuidUuid  = Guid.NewGuid();
            this.Timestamp = DateTimeUtil.ConvertToUnixTimestampInSeconds(DateTime.UtcNow);
        }