コード例 #1
0
        public int GetHashCode(object obj)
        {
            int hashCode = (ClientRequestId.GetHashCode() + FileUri.GetHashCode() + RelativeUri.GetHashCode() + Started.GetHashCode()) / 4;

            Log.Debug($"hashCode {hashCode}");
            return(hashCode);
        }
コード例 #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);
        }
コード例 #3
0
        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));
        }
コード例 #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"]));
        }
コード例 #5
0
        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)));
        }
コード例 #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);
     }
 }
コード例 #7
0
        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))));
        }
コード例 #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);
            }
        }
コード例 #9
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        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);
        }
コード例 #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));
        }
コード例 #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)));
        }
コード例 #12
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void op_Equals_object()
        {
            var obj = new RelativeUri("/");
            var comparand = new RelativeUri("/");

            Assert.True(obj.Equals(comparand as object));
        }
コード例 #13
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opImplicit_string_RelativeUri()
        {
            const string expected = "/";
            string actual = new RelativeUri(expected);

            Assert.Equal(expected, actual);
        }
コード例 #14
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opGreaterThan_RelativeUriNull_RelativeUri()
        {
            var comparand = new RelativeUri("/");

            Assert.False(null > comparand);
        }
コード例 #15
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void prop_Length_get()
        {
            const int expected = 4;
            var actual = new RelativeUri("/234").Length;

            Assert.Equal(expected, actual);
        }
コード例 #16
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opEquality_RelativeUri_RelativeUri()
        {
            var obj = new RelativeUri("/");
            var comparand = new RelativeUri("/");

            Assert.True(obj == comparand);
        }
コード例 #17
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opLesserThan_RelativeUri_RelativeUriNull()
        {
            var obj = new RelativeUri("/");

            Assert.False(obj < null);
        }
コード例 #18
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void op_GetHashCode()
        {
            var obj = new RelativeUri("/");

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

            Assert.Equal(expected, actual);
        }
コード例 #19
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opLesserThan_RelativeUriNull_RelativeUri()
        {
            var comparand = new RelativeUri("/");

            Assert.True(null < comparand);
        }
コード例 #20
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opLesserThan_RelativeUri_RelativeUriLesser()
        {
            var obj = new RelativeUri("/xyz");
            var comparand = new RelativeUri("/abc");

            Assert.False(obj < comparand);
        }
コード例 #21
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opInequality_RelativeUri_RelativeUriSame()
        {
            var obj = new RelativeUri("/");
            var comparand = obj;

            Assert.False(obj != comparand);
        }
コード例 #22
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opInequality_RelativeUri_RelativeUriDiffers()
        {
            var obj = new RelativeUri("/abc");
            var comparand = new RelativeUri("/xyz");

            Assert.True(obj != comparand);
        }
コード例 #23
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opImplicit_RelativeUri_stringEmpty()
        {
            var expected = new RelativeUri(string.Empty);
            RelativeUri actual = string.Empty;

            Assert.Equal(expected, actual);
        }
コード例 #24
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void op_Equals_objectDiffer()
        {
            var obj = new RelativeUri("/abc");
            var comparand = new RelativeUri("/xyz");

            Assert.False(obj.Equals(comparand as object));
        }
コード例 #25
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        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);
        }
コード例 #26
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void op_Equals_objectSame()
        {
            var obj = new RelativeUri("/");

            Assert.True(obj.Equals(obj as object));
        }
コード例 #27
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void op_CompareTo_object()
        {
            const int expected = 1;
            var actual = new RelativeUri("/").CompareTo(null as object);

            Assert.Equal(expected, actual);
        }
コード例 #28
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void op_ToString()
        {
            const string expected = "/";
            var actual = new RelativeUri(expected).ToString();

            Assert.Equal(expected, actual);
        }
コード例 #29
0
 private Uri GetAbsoluteUri()
 {
     return(new Uri(_baseUri + RelativeUri.TrimStart('/')));
 }
コード例 #30
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void prop_Length_getEmpty()
        {
            const int expected = 0;
            var actual = new RelativeUri(string.Empty).Length;

            Assert.Equal(expected, actual);
        }
コード例 #31
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opImplicit_RelativeUri_string()
        {
            var expected = new RelativeUri("/");
            RelativeUri actual = "/";

            Assert.Equal(expected, actual);
        }
コード例 #32
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opEquality_RelativeUri_RelativeUriDiffers()
        {
            var obj = new RelativeUri("/abc");
            var comparand = new RelativeUri("/xyz");

            Assert.False(obj == comparand);
        }
コード例 #33
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opGreaterThan_RelativeUri_RelativeUriNull()
        {
            var obj = new RelativeUri("/");

            Assert.True(obj > null);
        }
コード例 #34
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opGreaterThan_RelativeUriGreater_RelativeUri()
        {
            var obj = new RelativeUri("/xyz");
            var comparand = new RelativeUri("/abc");

            Assert.True(obj > comparand);
        }
コード例 #35
0
 public void EnsurePathTrailingSlash_Relative()
 {
     RelativeUri
     .Invoking(u => u.EnsurePathTrailingSlash())
     .Should().Throw <ArgumentException>();
 }
コード例 #36
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opExplicit_RelativeUri_UriRelative()
        {
            var expected = new RelativeUri("/");
            RelativeUri actual = new Uri("/", UriKind.Relative);

            Assert.Equal(expected, actual);
        }
コード例 #37
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opImplicit_Uri_RelativeUri()
        {
            var expected = new Uri("/", UriKind.Relative);
            Uri actual = new RelativeUri(expected);

            Assert.Equal(expected, actual);
        }
コード例 #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);
        }
コード例 #39
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void opGreaterThan_RelativeUri_RelativeUri()
        {
            var obj = new RelativeUri("/");
            var comparand = new RelativeUri("/");

            Assert.False(obj > comparand);
        }
コード例 #40
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        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);
        }
コード例 #41
0
 public ContentBEndpoint(RelativeUri relativeUri) : base(relativeUri)
 {
 }
コード例 #42
0
 public override int GetHashCode()
 {
     return(RelativeUri.GetHashCode());
 }
コード例 #43
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void op_CompareTo_objectSame()
        {
            var obj = new RelativeUri("/");

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

            Assert.Equal(expected, actual);
        }
コード例 #44
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void op_Equals_RelativeUriSame()
        {
            var obj = new RelativeUri("/");
            var comparand = obj;

            Assert.True(obj.Equals(comparand));
        }
コード例 #45
0
ファイル: RelativeUri.Facts.cs プロジェクト: KarlDirck/cavity
        public void op_Equals_RelativeUriUnequal()
        {
            var obj = new RelativeUri("/abc");
            var comparand = new RelativeUri("/xyz");

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