コード例 #1
0
        public IWebRequestTracer TraceWebRequest(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                logger.Warn($"{this} TraceWebRequest(string): url must not be null or empty");
                return(NullWebRequestTracer.Instance);
            }

            if (!WebRequestTracer.IsValidUrlScheme(url))
            {
                logger.Warn($"{this} TraceWebRequest(string): url \"{url}\" does not have a valid scheme");
                return(NullWebRequestTracer.Instance);
            }

            if (logger.IsDebugEnabled)
            {
                logger.Debug($"{this} TraceWebRequest({url})");
            }

            lock (lockObject)
            {
                if (isFinished)
                {
                    return(NullWebRequestTracer.Instance);
                }

                var session = GetOrSplitCurrentSessionByEvents();
                RecordTopLevelEventInteraction();
                return(session.TraceWebRequest(url));
            }
        }
コード例 #2
0
 public void AValidSchemeDoesNotStartWithADigit()
 {
     // when it does not start with a digit, then it's valid
     Assert.That(WebRequestTracer.IsValidUrlScheme("a1://some.host"), Is.True);
     // when it starts with a digit, then it's invalid
     Assert.That(WebRequestTracer.IsValidUrlScheme("1a://some.host"), Is.False);
 }
コード例 #3
0
        public IWebRequestTracer TraceWebRequest(string url)
        {
            if (string.IsNullOrEmpty(url))
            {
                Logger.Warn($"{this} TraceWebRequest (String): url must not be null or empty");
                return(NullWebRequestTracer.Instance);
            }
            if (!WebRequestTracer.IsValidUrlScheme(url))
            {
                Logger.Warn($"{this} TraceWebRequest (String): url \"{url}\" does not have a valid scheme");
                return(NullWebRequestTracer.Instance);
            }
            if (Logger.IsDebugEnabled)
            {
                Logger.Debug($"{this} TraceWebRequest(${url})");
            }

            lock (LockObject)
            {
                if (!ThisAction.IsActionLeft)
                {
                    var tracer = new WebRequestTracer(Logger, this, Beacon, url);
                    ThisComposite.StoreChildInList(tracer);

                    return(tracer);
                }
            }

            return(NullWebRequestTracer.Instance);
        }
コード例 #4
0
 public void ASchemeIsInvalidIfInvalidCharactersAreEncountered()
 {
     // then
     Assert.That(WebRequestTracer.IsValidUrlScheme("a()[]{}@://some.host"), Is.False);
 }
コード例 #5
0
 public void AValidSchemeAllowsUpperCaseLettersToo()
 {
     // when the url scheme contains all allowed characters
     Assert.That(WebRequestTracer.IsValidUrlScheme("Obp1e+nZK6i.t-://some.host"), Is.True);
 }
コード例 #6
0
 public void AValidSchemeOnlyContainsLettersDigitsPlusPeriodOrHyphen()
 {
     // when the url scheme contains all allowed characters
     Assert.That(WebRequestTracer.IsValidUrlScheme("b1+Z6.-://some.host"), Is.True);
 }
コード例 #7
0
 public void AValidSchemeStartsWithALetter()
 {
     // when starting with lower case letter, then
     Assert.That(WebRequestTracer.IsValidUrlScheme("a://some.host"), Is.True);
 }
コード例 #8
0
 public void NullIsNotAValidUrlScheme()
 {
     // then
     Assert.That(WebRequestTracer.IsValidUrlScheme(null), Is.False);
 }