Ejemplo n.º 1
0
        private void SnapProperties(HttpRequestMessage httpRequest)
        {
            Assumption.AssertNotNull(httpRequest, nameof(httpRequest));

            this.Url         = httpRequest.RequestUri.AbsoluteUri;
            this.QueryString = httpRequest.RequestUri.Query;
            this.Params      = null;

            this.Headers = new Dictionary <string, string>(httpRequest.Headers.Count());
            foreach (var header in httpRequest.Headers)
            {
                this.Headers.Add(header.Key, StringUtility.Combine(header.Value, ", "));
            }

            this.Method = httpRequest.Method.Method;
            switch (this.Method.ToUpper())
            {
            case "POST":
                var task = httpRequest.Content.ReadAsStringAsync();
                task.Wait();
                this.PostBody   = task.Result;
                this.PostParams = null;
                break;

            case "GET":
                this.GetParams = null;
                break;
            }

////#if NETFX
////            string userIP = null;
////            const string HttpContextProperty = "MS_HttpContext";
////            const string RemoteEndpointMessagePropery = "System.ServiceModel.Channels.RemoteEndpointMessageProperty";
////            if (httpRequest.Properties.ContainsKey(HttpContextProperty))
////            {
////                HttpContext ctx = httpRequest.Properties[HttpContextProperty] as HttpContext;
////                if (ctx != null)
////                {
////                    userIP = ctx.Request.UserHostAddress;
////                }
////            }
////            else if (httpRequest.Properties.ContainsKey(RemoteEndpointMessagePropery))
////            {
////                RemoteEndpointMessageProperty remoteEndpoint =
////                    httpRequest.Properties[RemoteEndpointMessagePropery] as RemoteEndpointMessageProperty;
////                if (remoteEndpoint != null)
////                {
////                    userIP = remoteEndpoint.Address;
////                }
////            }
////            this.UserIp = userIP;
////#endif
        }
Ejemplo n.º 2
0
        private void SnapProperties(HttpRequest httpRequest)
        {
            Assumption.AssertNotNull(httpRequest, nameof(httpRequest));

            this.Url         = httpRequest.Host.Value + httpRequest.Path;
            this.QueryString = httpRequest.QueryString.Value;
            this.Params      = null;

            this.Headers = new Dictionary <string, string>(httpRequest.Headers.Count());
            foreach (var header in httpRequest.Headers)
            {
                this.Headers.Add(header.Key, StringUtility.Combine(header.Value, ", "));
            }

            this.Method = httpRequest.Method;
        }
Ejemplo n.º 3
0
        private void SnapProperties(RollbarHttpAttributes httpContext)
        {
            Assumption.AssertNotNull(httpContext, nameof(httpContext));

            this.Url         = httpContext.Host.Value + httpContext.Path;
            this.QueryString = httpContext.Query.Value;
            this.Params      = null;

            this.Headers = new Dictionary <string, string>(httpContext.Headers.Count());
            foreach (var header in httpContext.Headers)
            {
                if (header.Value.Count() == 0)
                {
                    continue;
                }

                this.Headers.Add(header.Key, StringUtility.Combine(header.Value, ", "));
            }

            this.Method = httpContext.Method;
        }
Ejemplo n.º 4
0
        private static string DetectTargetFrameworks()
        {
            var targetFrameworks = RuntimeEnvironmentUtility.GetAssemblyTargetFrameworks(typeof(Data));

            return(StringUtility.Combine(targetFrameworks, "; "));
        }