public void MeasurementAnalyticsClient_AdjustUriBeforeRequest_Adds_Uid_Parameter()
        {
            var originalUri = new Uri("http://anything.really.com/something#" + DateTime.UtcNow.ToString("o"));
            var client      = new MeasurementAnalyticsClient()
            {
                UserId = "Testing"
            };

            var actual = client.AdjustUriBeforeRequest(originalUri);

            StringAssert.Contains(actual.Query, "uid=Testing");
        }
示例#2
0
        /// <summary>
        /// Act as a middleman between the background sender and the actual http client sender
        /// so we can drop opt-out or sampled out requests already in the queue, adjust the uri
        /// for queue times and optionally debug them.
        /// </summary>
        /// <param name="uri">Uri to modify or inspect before it is sent.</param>
        /// <param name="token">CancellationToken to cancel any network request, e.g. if shutting down.</param>
        /// <remarks>
        /// Because user agent is not persisted unsent URIs that are saved and then sent after an upgrade
        /// will have the new user agent string not the actual one that generated them.
        /// </remarks>
        private bool Request(Uri uri, CancellationToken token)
        {
            if (sessionManager.VisitorStatus != VisitorStatus.Active)
            {
                return(true);
            }

            uri = client.AdjustUriBeforeRequest(uri);
            protocolDebugger.Dump(uri, DebugWriter);

            return(Requester(uri, token));
        }
示例#3
0
        /// <summary>
        /// Pre-process the HttpRequestMessage before it is sent. This includes adding the user agent for tracking
        /// and for debug builds writing out the debug information to the console log.
        /// </summary>
        /// <param name="requestMessage">HttpRequestMessage to modify or inspect before it is sent.</param>
        /// <remarks>
        /// Because user agent is not persisted unsent URIs that are saved and then sent after an upgrade
        /// will have the new user agent string not the actual one that generated them.
        /// </remarks>
        private static void PreprocessHttpRequest(HttpRequestMessage requestMessage)
        {
            if (sessionManager.VisitorStatus != VisitorStatus.Active)
            {
                requestMessage.RequestUri = null;
                return;
            }

            requestMessage.RequestUri = client.AdjustUriBeforeRequest(requestMessage.RequestUri);
            AddUserAgent(requestMessage.Headers.UserAgent);
            DebugRequest(requestMessage);
        }