public int GetHashCode(object obj)
        {
            int hashCode = (ClientRequestId.GetHashCode() + FileUri.GetHashCode() + RelativeUri.GetHashCode() + Started.GetHashCode()) / 4;

            Log.Debug($"hashCode {hashCode}");
            return(hashCode);
        }
Ejemplo n.º 2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (HttpMethod != 0)
            {
                hash ^= HttpMethod.GetHashCode();
            }
            if (appEngineRouting_ != null)
            {
                hash ^= AppEngineRouting.GetHashCode();
            }
            if (RelativeUri.Length != 0)
            {
                hash ^= RelativeUri.GetHashCode();
            }
            hash ^= Headers.GetHashCode();
            if (Body.Length != 0)
            {
                hash ^= Body.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public static Response Execute(RelativeUri url, Func <ISchedulerWrapper> getScheduler)
        {
            var scheduler = getScheduler();
            var p         = GetMethodParameters(url.ParseQueryString());

            p.method.Invoke(scheduler, p.parameters.ToArray());
            return(new Response.RedirectResponse(p.redirect));
        }
Ejemplo n.º 4
0
        public static Response Execute(RelativeUri url)
        {
            var querystring = url.ParseQueryString();
            var resource    = querystring["r"];

            resource = string.Format("{0}.Resources.{1}", assembly.FullName.Split(',')[0], resource);
            var content = ReadResource(resource);

            return(new Response.ContentResponse(content: content, contentType: querystring["t"]));
        }
        public static Response Execute(RelativeUri url, Func <ISchedulerWrapper> getScheduler)
        {
            var scheduler = getScheduler();
            var qs        = url.ParseQueryString();
            var highlight = qs["highlight"];
            var group     = qs["group"];
            var triggers  = GetTriggers(scheduler, group);
            var paused    = scheduler.IsTriggerGroupPaused(group);
            var v         = Views.Views.TriggerGroup(group, paused, url.PathAndQuery, highlight, triggers);

            return(new Response.XDocumentResponse(Helpers.XHTML(v)));
        }
Ejemplo n.º 6
0
 public void RelativeUri_Unhappy(string path, string expectedMessage)
 {
     if (expectedMessage == null)
     {
         var ex = Assert.Throws <ArgumentNullException>(() => { RelativeUri target = path; });
         ex.Message.Should().Be("Value cannot be null. (Parameter 'value')");
     }
     else
     {
         var ex = Assert.Throws <ArgumentException>(() => { RelativeUri target = path; });
         ex.Message.Should().Be(expectedMessage);
     }
 }
        public static Response Execute(RelativeUri url, Func <ISchedulerWrapper> getScheduler)
        {
            var scheduler   = getScheduler();
            var querystring = url.ParseQueryString();
            var highlight   = querystring["highlight"];
            var group       = querystring["group"];
            var job         = querystring["job"];
            var jobKey      = new JobKey(job, group);
            var triggers    = GetTriggers(scheduler, jobKey);
            var m           = new TriggersByJobModel(triggers, url.PathAndQuery, group, job, highlight);

            return(new Response.XDocumentResponse(Helpers.XHTML(Views.Views.TriggersByJob(m))));
        }
Ejemplo n.º 8
0
        public void RelativeUri_Happy()
        {
            var         url  = "stub/here";
            RelativeUri uri1 = url;
            RelativeUri uri2 = "/" + url;
            RelativeUri uri3 = url + "/";

            using (new AssertionScope())
            {
                uri1.ToString().Should().Be(url);
                uri2.ToString().Should().Be(url);
                uri3.ToString().Should().Be(url);
            }
        }
Ejemplo n.º 9
0
        public void ctor_SerializationInfo_StreamingContext()
        {
            var expected = new RelativeUri("/");
            RelativeUri actual;

            using (Stream stream = new MemoryStream())
            {
                var formatter = new BinaryFormatter();
                formatter.Serialize(stream, new RelativeUri("/"));
                stream.Position = 0;
                actual = (RelativeUri)formatter.Deserialize(stream);
            }

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 10
0
        public static Response Execute(RelativeUri url)
        {
            var thisUrl    = url.PathAndQuery.Split('?')[0];
            var qs         = url.ParseQueryString();
            var pageSize   = GetPageSize(qs);
            var pagination = new PaginationInfo(
                firstItemIndex: GetStartIndex(qs),
                pageSize: pageSize,
                totalItemCount: logsQ.Count(),
                pageUrl: "log.ashx?start=!0&max=" + pageSize);
            var logs = logsQ.Skip(pagination.FirstItemIndex).Take(pagination.PageSize).ToList();
            var v    = GetView(qs.AllKeys);
            var view = v.Value(logs, pagination, thisUrl);

            return(new Response.XDocumentResponse(view, v.Key));
        }
Ejemplo n.º 11
0
        public static Response Execute(RelativeUri uri, Func <ISchedulerWrapper> getScheduler)
        {
            var scheduler   = getScheduler();
            var querystring = QueryStringParser.ParseQueryString(uri.Query);

            var group       = querystring["group"];
            var jobNames    = scheduler.GetJobKeys(GroupMatcher <JobKey> .GroupEquals(group));
            var runningJobs = scheduler.GetCurrentlyExecutingJobs();
            var jobs        = jobNames.Select(j => {
                var job           = scheduler.GetJobDetail(j);
                var interruptible = typeof(IInterruptableJob).IsAssignableFrom(job.JobType);
                var jobContext    = runningJobs.FirstOrDefault(r => r.JobDetail.Key.ToString() == job.Key.ToString());
                return(new JobWithContext(job, jobContext, interruptible));
            });
            var paused    = scheduler.IsJobGroupPaused(group);
            var highlight = querystring["highlight"];
            var view      = Views.Views.JobGroup(group, paused, highlight, uri.PathAndQuery, jobs);

            return(new Response.XDocumentResponse(Helpers.XHTML(view)));
        }
Ejemplo n.º 12
0
        public void op_Equals_object()
        {
            var obj = new RelativeUri("/");
            var comparand = new RelativeUri("/");

            Assert.True(obj.Equals(comparand as object));
        }
Ejemplo n.º 13
0
        public void opImplicit_string_RelativeUri()
        {
            const string expected = "/";
            string actual = new RelativeUri(expected);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 14
0
        public void opGreaterThan_RelativeUriNull_RelativeUri()
        {
            var comparand = new RelativeUri("/");

            Assert.False(null > comparand);
        }
Ejemplo n.º 15
0
        public void prop_Length_get()
        {
            const int expected = 4;
            var actual = new RelativeUri("/234").Length;

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 16
0
        public void opEquality_RelativeUri_RelativeUri()
        {
            var obj = new RelativeUri("/");
            var comparand = new RelativeUri("/");

            Assert.True(obj == comparand);
        }
Ejemplo n.º 17
0
        public void opLesserThan_RelativeUri_RelativeUriNull()
        {
            var obj = new RelativeUri("/");

            Assert.False(obj < null);
        }
Ejemplo n.º 18
0
        public void op_GetHashCode()
        {
            var obj = new RelativeUri("/");

            var expected = obj.ToString().GetHashCode();
            var actual = obj.GetHashCode();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 19
0
        public void opLesserThan_RelativeUriNull_RelativeUri()
        {
            var comparand = new RelativeUri("/");

            Assert.True(null < comparand);
        }
Ejemplo n.º 20
0
        public void opLesserThan_RelativeUri_RelativeUriLesser()
        {
            var obj = new RelativeUri("/xyz");
            var comparand = new RelativeUri("/abc");

            Assert.False(obj < comparand);
        }
Ejemplo n.º 21
0
        public void opInequality_RelativeUri_RelativeUriSame()
        {
            var obj = new RelativeUri("/");
            var comparand = obj;

            Assert.False(obj != comparand);
        }
Ejemplo n.º 22
0
        public void opInequality_RelativeUri_RelativeUriDiffers()
        {
            var obj = new RelativeUri("/abc");
            var comparand = new RelativeUri("/xyz");

            Assert.True(obj != comparand);
        }
Ejemplo n.º 23
0
        public void opImplicit_RelativeUri_stringEmpty()
        {
            var expected = new RelativeUri(string.Empty);
            RelativeUri actual = string.Empty;

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 24
0
        public void op_Equals_objectDiffer()
        {
            var obj = new RelativeUri("/abc");
            var comparand = new RelativeUri("/xyz");

            Assert.False(obj.Equals(comparand as object));
        }
Ejemplo n.º 25
0
        public void op_CompareTo_RelativeUriEqual()
        {
            var obj = new RelativeUri("/");
            var comparand = new RelativeUri("/");

            const int expected = 0;
            var actual = obj.CompareTo(comparand);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 26
0
        public void op_Equals_objectSame()
        {
            var obj = new RelativeUri("/");

            Assert.True(obj.Equals(obj as object));
        }
Ejemplo n.º 27
0
        public void op_CompareTo_object()
        {
            const int expected = 1;
            var actual = new RelativeUri("/").CompareTo(null as object);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 28
0
        public void op_ToString()
        {
            const string expected = "/";
            var actual = new RelativeUri(expected).ToString();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 29
0
 private Uri GetAbsoluteUri()
 {
     return(new Uri(_baseUri + RelativeUri.TrimStart('/')));
 }
Ejemplo n.º 30
0
        public void prop_Length_getEmpty()
        {
            const int expected = 0;
            var actual = new RelativeUri(string.Empty).Length;

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 31
0
        public void opImplicit_RelativeUri_string()
        {
            var expected = new RelativeUri("/");
            RelativeUri actual = "/";

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 32
0
        public void opEquality_RelativeUri_RelativeUriDiffers()
        {
            var obj = new RelativeUri("/abc");
            var comparand = new RelativeUri("/xyz");

            Assert.False(obj == comparand);
        }
Ejemplo n.º 33
0
        public void opGreaterThan_RelativeUri_RelativeUriNull()
        {
            var obj = new RelativeUri("/");

            Assert.True(obj > null);
        }
Ejemplo n.º 34
0
        public void opGreaterThan_RelativeUriGreater_RelativeUri()
        {
            var obj = new RelativeUri("/xyz");
            var comparand = new RelativeUri("/abc");

            Assert.True(obj > comparand);
        }
Ejemplo n.º 35
0
 public void EnsurePathTrailingSlash_Relative()
 {
     RelativeUri
     .Invoking(u => u.EnsurePathTrailingSlash())
     .Should().Throw <ArgumentException>();
 }
Ejemplo n.º 36
0
        public void opExplicit_RelativeUri_UriRelative()
        {
            var expected = new RelativeUri("/");
            RelativeUri actual = new Uri("/", UriKind.Relative);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 37
0
        public void opImplicit_Uri_RelativeUri()
        {
            var expected = new Uri("/", UriKind.Relative);
            Uri actual = new RelativeUri(expected);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 38
0
        public bool InterpretHeaders()
        {
            //
            // when all the headers are parsed, this method will
            // interpret the values of the "special" headers and set
            // the corresponding properties to the correct values.
            //
            if (Headers == null)
            {
                var exception = new Exception("Don't have headers yet");
#if DEBUG
                if (HttpTraceHelper.ExceptionThrown.TraceVerbose)
                {
                    HttpTraceHelper.WriteLine("HttpListenerWebRequest#" + HttpTraceHelper.HashString(this) +
                                              "::InterpretHeaders() throwing: " + exception);
                }
#endif
                throw exception;
            }

            if (_interpretHeadersCalled)
            {
                return(false);
            }

            _interpretHeadersCalled = true;

            //
            // Connection && KeepAlive
            //
            Connection = Headers["Connection"];
            KeepAlive  = Connection == null ||
                         Connection.ToLower(CultureInfo.InvariantCulture).IndexOf("close") == -1;

            //
            // RequestUri
            //
            Host       = Headers["Host"];
            RequestUri = null;
            // we should try this only if this is a fully qualified Uri
            if (RelativeUri.StartsWith("http://") || RelativeUri.StartsWith("https://"))
            {
                try
                {
                    RequestUri = new Uri(RelativeUri);
                }
                catch (Exception exception)
                {
#if DEBUG
                    if (HttpTraceHelper.ExceptionCaught.TraceVerbose)
                    {
                        HttpTraceHelper.WriteLine("HttpListenerWebRequest#" + HttpTraceHelper.HashString(this) +
                                                  "::InterpretHeaders() caught exception in Uri..ctor(): " + exception);
                    }
#endif
                }
            }

            if (RequestUri == null || !(RequestUri.Scheme.Equals("http") || RequestUri.Scheme.Equals("https")))
            {
                try
                {
                    RequestUri = RelativeUri[0] != '/'
                                     ? new Uri("http://" + Host + "/" + RelativeUri)
                                     : new Uri("http://" + Host + RelativeUri);
                }
                catch (Exception exception)
                {
#if DEBUG
                    if (HttpTraceHelper.ExceptionCaught.TraceVerbose)
                    {
                        HttpTraceHelper.WriteLine("HttpListenerWebRequest#" + HttpTraceHelper.HashString(this) +
                                                  "::InterpretHeaders() caught exception in Uri..ctor(): " + exception);
                    }
#endif
                }
            }

            //
            // Chunked
            //
            var value = Headers["Transfer-Encoding"];
            Chunked = value != null && value.ToLower(CultureInfo.InvariantCulture).IndexOf("chunked") >= 0;

            //
            // ContentLength
            //
            if (Chunked)
            {
                //
                // if the client is chunking we ignore Content-Length
                //
                ContentLength = -1;
            }
            else
            {
                ContentLength = 0;
                value         = Headers["Content-Length"];
                if (value != null)
                {
                    try
                    {
                        ContentLength = Int64.Parse(value);
                    }
                    catch (Exception exception)
                    {
#if DEBUG
                        if (HttpTraceHelper.ExceptionCaught.TraceVerbose)
                        {
                            HttpTraceHelper.WriteLine("HttpListenerWebRequest#" + HttpTraceHelper.HashString(this) +
                                                      "::InterpretHeaders() caught exception in Int64.Parse(): " +
                                                      exception);
                        }
#endif
                    }
                }
            }

#if DEBUG
            if (HttpTraceHelper.InternalLog.TraceVerbose)
            {
                HttpTraceHelper.WriteLine("HttpListenerWebRequest#" + HttpTraceHelper.HashString(this) +
                                          "::InterpretHeaders() ContentLength:" + ContentLength + " Chunked:" +
                                          Chunked);
            }
#endif

            // check validity of request delimiters
            // i.e.: will we be able to tell when the request is over?
            // if not, return a bad request and close the connection
            if ((string.Compare(Method, "post", true, CultureInfo.InvariantCulture) == 0 ||
                 string.Compare(Method, "put", true, CultureInfo.InvariantCulture) == 0) && !Uploading)
            {
                //
                // connection Keep Alive, neither Chunking nor Content Length
                // sorry, can't do it: will not be able to tell the end of the body
                //
#if DEBUG
                if (HttpTraceHelper.InternalLog.TraceVerbose)
                {
                    HttpTraceHelper.WriteLine("HttpListenerWebRequest#" + HttpTraceHelper.HashString(this) +
                                              "::InterpretHeaders() Client's not chunking, didn't set Content-Length and wants to do Keep-Alive... what a fool!");
                }
#endif
                return(false);
            }

            if (!Uploading)
            {
                //
                // we can already start receiving the next request
                //
#if DEBUG
                if (HttpTraceHelper.InternalLog.TraceVerbose)
                {
                    HttpTraceHelper.WriteLine("HttpListenerWebRequest#" + HttpTraceHelper.HashString(this) +
                                              "::InterpretHeaders() Client's not uploading calling Close()");
                }
#endif
                Close();
            }

            return(true);
        }
Ejemplo n.º 39
0
        public void opGreaterThan_RelativeUri_RelativeUri()
        {
            var obj = new RelativeUri("/");
            var comparand = new RelativeUri("/");

            Assert.False(obj > comparand);
        }
Ejemplo n.º 40
0
        public void op_CompareTo_objectLesser()
        {
            var obj = new RelativeUri("/xyz");
            object comparand = new RelativeUri("/abc");

            const int expected = 23;
            var actual = obj.CompareTo(comparand);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 41
0
 public ContentBEndpoint(RelativeUri relativeUri) : base(relativeUri)
 {
 }
 public override int GetHashCode()
 {
     return(RelativeUri.GetHashCode());
 }
Ejemplo n.º 43
0
        public void op_CompareTo_objectSame()
        {
            var obj = new RelativeUri("/");

            const int expected = 0;
            var actual = obj.CompareTo(obj as object);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 44
0
        public void op_Equals_RelativeUriSame()
        {
            var obj = new RelativeUri("/");
            var comparand = obj;

            Assert.True(obj.Equals(comparand));
        }
Ejemplo n.º 45
0
        public void op_Equals_RelativeUriUnequal()
        {
            var obj = new RelativeUri("/abc");
            var comparand = new RelativeUri("/xyz");

            Assert.False(obj.Equals(comparand));
        }
Ejemplo n.º 46
0
 public Endpoint(RelativeUri relativeUri)
 {
     this.relativeUri = relativeUri;
 }
Ejemplo n.º 47
0
 public void ChangeBase_RelativeNewBaseUri()
 {
     RelativeUri
     .Invoking(u => AnyUri.ChangeBase(AnyUri, u))
     .Should().Throw <ArgumentException>();
 }