The Request information is stored in the Http interface. Two arguments are required: url and method.
Пример #1
0
        /// <summary>
        /// Prevents a default instance of the <see cref="JsonPacket"/> class from being created.
        /// </summary>
        private JsonPacket()
        {
            // Get assemblies.
            Modules = SystemUtil.GetModules();

            // The current hostname
            ServerName = Environment.MachineName;

            // Create timestamp
            TimeStamp = DateTime.UtcNow;

            // Default logger.
            Logger = "root";

            // Default error level.
            Level = ErrorLevel.Error;

            // Create a guid.
            EventID = Guid.NewGuid().ToString("n");

            // Project
            Project = "default";

            // Platform
            Platform = "csharp";

            // Get data from the HTTP request
            Request = SentryRequest.GetRequest();

            // Get the user data from the HTTP context or environment
            User = Request != null
                       ? Request.GetUser()
                       : new SentryUser(Environment.UserName);
        }
Пример #2
0
        /// <summary>
        /// Gets the request.
        /// </summary>
        /// <returns>
        /// If an HTTP contest is available, an instance of <see cref="SentryRequest"/>, otherwise <c>null</c>.
        /// </returns>
        public static SentryRequest GetRequest()
        {
            try
            {
                var request = new SentryRequest();
                return(HasHttpContext ? request : null);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }

            return(null);
        }
Пример #3
0
        /// <summary>
        /// Creates a new instance of <see cref="SentryRequest"/>
        /// for the current packet.
        /// </summary>
        /// <returns>A new instance of <see cref="SentryRequest"/> with information relating to the current HTTP request</returns>
        public ISentryRequest Create()
        {
            // NOTE: We're using dynamic to not require a reference to System.Web.
            GetHttpContext();

            if (!HasHttpContext || HttpContext.Request == null)
            {
                return(OnCreate(null));
            }

            var request = new SentryRequest()
            {
                Url         = HttpContext.Request.Url.ToString(),
                Method      = HttpContext.Request.HttpMethod,
                Environment = Convert(x => x.Request.ServerVariables),
                Headers     = Convert(x => x.Request.Headers),
                Cookies     = Convert(x => x.Request.Cookies),
                Data        = Convert(x => x.Request.Form),
                QueryString = HttpContext.Request.QueryString.ToString()
            };

            return(OnCreate(request));
        }
Пример #4
0
        /// <summary>
        /// Creates a new instance of <see cref="SentryRequest"/>
        /// for the current packet.
        /// </summary>
        /// <returns>A new instance of <see cref="SentryRequest"/> with information relating to the current HTTP request</returns>
        public ISentryRequest Create()
        {
            if (!HasHttpContext || HttpContext.Request == null)
            {
                return(OnCreate(null));
            }

            var request = new SentryRequest
            {
                Url         = HttpContext.Request.Url.ToString(),
                Method      = HttpContext.Request.HttpMethod,
                Environment = Convert(x => x.Request.ServerVariables),
                Headers     = Convert(x => x.Request.Headers),
                #if net35
                Cookies = ConvertHttpCookie(x => x.Request.Cookies),
                #else
                Cookies = Convert(x => x.Request.Cookies),
                #endif
                Data        = BodyConvert(),
                QueryString = HttpContext.Request.QueryString.ToString()
            };

            return(OnCreate(request));
        }
Пример #5
0
        /// <summary>
        /// Gets the request.
        /// </summary>
        /// <returns>
        /// If an HTTP contest is available, an instance of <see cref="SentryRequest"/>, otherwise <c>null</c>.
        /// </returns>
        public static SentryRequest GetRequest()
        {
            var request = new SentryRequest();

            return(request.HasHttpContext ? request : null);
        }
Пример #6
0
 /// <summary>
 /// Called when the <see cref="SentryRequest"/> has been created. Can be overridden to
 /// adjust the values of the <paramref name="request"/> before it is sent to Sentry.
 /// </summary>
 /// <param name="request">The HTTP request information.</param>
 /// <returns>
 /// The <see cref="SentryRequest"/>.
 /// </returns>
 public virtual SentryRequest OnCreate(SentryRequest request)
 {
     return(request);
 }
Пример #7
0
 /// <summary>
 /// Gets the request.
 /// </summary>
 /// <returns>
 /// If an HTTP contest is available, an instance of <see cref="SentryRequest"/>, otherwise <c>null</c>.
 /// </returns>
 public static SentryRequest GetRequest()
 {
     var request = new SentryRequest();
     return request.HasHttpContext ? request : null;
 }
        /// <summary>
        /// Creates a new instance of <see cref="SentryRequest"/>
        /// for the current packet.
        /// </summary>
        /// <returns>A new instance of <see cref="SentryRequest"/> with information relating to the current HTTP request</returns>
        public ISentryRequest Create()
        {
            // NOTE: We're using dynamic to not require a reference to System.Web.
            GetHttpContext();

            if (!HasHttpContext || HttpContext.Request == null)
                return OnCreate(null);

            var request = new SentryRequest()
            {
                Url = HttpContext.Request.Url.ToString(),
                Method = HttpContext.Request.HttpMethod,
                Environment = Convert(x => x.Request.ServerVariables),
                Headers = Convert(x => x.Request.Headers),
                Cookies = Convert(x => x.Request.Cookies),
                Data = Convert(x => x.Request.Form),
                QueryString = HttpContext.Request.QueryString.ToString()
            };

            return OnCreate(request);
        }
 /// <summary>
 /// Called when the <see cref="SentryRequest"/> has been created. Can be overridden to
 /// adjust the values of the <paramref name="request"/> before it is sent to Sentry.
 /// </summary>
 /// <param name="request">The HTTP request information.</param>
 /// <returns>
 /// The <see cref="SentryRequest"/>.
 /// </returns>
 public virtual SentryRequest OnCreate(SentryRequest request)
 {
     return request;
 }