Beispiel #1
0
        void OnSession(Session session)
        {
            try {
                if (shouldStopSending_)
                {
                    return;
                }

                var requestUri = Uri.IsWellFormedUriString(session.Request.RequestLine.URI, UriKind.Absolute)
                                ? new Uri(session.Request.RequestLine.URI, UriKind.Absolute)
                                : new Uri(string.Format("http://{0}{1}", session.Request.Headers.Host, session.Request.PathAndQuery), UriKind.Absolute);
                var    statusCode   = session.Response.StatusLine.StatusCode;
                var    requestBody  = ApiStringUtil.RemoveTokenFromRequestBody(session.Request.BodyAsString);
                var    responseBody = session.Response.BodyAsString;
                string httpDate;
                session.Response.Headers.Headers.TryGetValue(DateHeaderKey, out httpDate);

                KcvdbClient.SendRequestDataAsync(
                    requestUri,
                    statusCode,
                    requestBody,
                    responseBody,
                    httpDate);
            }
            catch (Exception ex) {
                TelemetryClient.TrackException("Failed to enqueue session data", ex);
                if (ex.IsCritical())
                {
                    throw;
                }
            }
        }
Beispiel #2
0
        public void RemoveTokenFromRequestBodyTest()
        {
            var input    = "api%5Ftoken=b4206b74b7563ec684336f054582605bb3af409b&api%5Fverno=1";
            var expected = "api%5Fverno=1";

            var actual = ApiStringUtil.RemoveTokenFromRequestBody(input);

            Assert.AreEqual(expected, actual);
        }