Esempio n. 1
0
		private Action AdaptHttpContext(IHttpContext httpContext, ServerLog serverLog)
		{
			if (pathsToFilter.Contains(httpContext.Request.Url.AbsolutePath))
				return null;
			if (ignoreHilo && httpContext.Request.Url.AbsolutePath.StartsWith("/docs/Raven/Hilo/"))
				return null;
			if (httpContext.Request.Headers["Raven-Timer-Request"] != null)
				return null;

			var requestStream = new MemoryStream();
			httpContext.SetRequestFilter(stream =>
			{
				stream.CopyTo(requestStream);
				return new MemoryStream(requestStream.ToArray());
			});
			var responseStream = new MemoryStream();
			httpContext.SetResponseFilter(stream => new MultiStreamWriter(responseStream, stream));

			var trackedRequest = new TrackedRequest
			{
				Method = httpContext.Request.HttpMethod,
				Url = httpContext.Request.RawUrl,
				RequestHeaders = new NameValueCollection(httpContext.Request.Headers),
				RequestContent = requestStream,
				ResponseContent = responseStream,
				ResponseHeaders = httpContext.Response.GetHeaders(),
			};

			return () =>
			{
				trackedRequest.Status = httpContext.Response.StatusCode;
				serverLog.AddRequest(trackedRequest);
			};
		}
Esempio n. 2
0
		private void StartServers_Click(object sender, EventArgs e)
		{
			Reset();

			for (int i = 0; i < NumberOfServers.Value; i++)
			{
				var port = 8079 - i;
				NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port);
				var ravenDbServer = new RavenDbServer(new RavenConfiguration
				{
					Port = port,
					//DataDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Server-" + port, "Data"),
					RunInMemory = true,
                    AnonymousUserAccessMode = AnonymousUserAccessMode.Admin,
					ServerName = "DB-" + (i + 1).ToString("X2"),
					ClusterName = "Visual Host Servers",
				});

				var serverLog = new ServerLog
				{
					Server = ravenDbServer,
					Dock = DockStyle.Fill,
					Url = ravenDbServer.Server.Configuration.ServerUrl
				};
				ServerTabs.TabPages.Add(serverLog.Url);
				var tabPage = ServerTabs.TabPages[ServerTabs.TabPages.Count - 1];
				tabPage.Tag = serverLog;
				ravenDbServer.Server.BeforeDispatchingRequest = context =>
				{
					var adaptHttpContext = AdaptHttpContext(context, serverLog);
					if (adaptHttpContext != null)
					{
						var increment = serverLog.IncrementRequest();
						BeginInvoke((Action) (() =>
						{
							tabPage.Text = string.Format("{0} ({1})", serverLog.Url, increment);
						}));
					}

					return adaptHttpContext;
				};
				servers.Add(ravenDbServer);

				tabPage.Controls.Add(serverLog);
			}
		}
Esempio n. 3
0
        private void StartServers_Click(object sender, EventArgs e)
        {
            Reset();

            for (int i = 0; i < NumberOfServers.Value; i++)
            {
                var port = 8079 - i;
                NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port);
                var ravenDbServer = new RavenDbServer(new RavenConfiguration
                {
                    Port = port,
                    //DataDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Server-" + port, "Data"),
                    RunInMemory             = true,
                    AnonymousUserAccessMode = AnonymousUserAccessMode.Admin,
                    ServerName  = "DB-" + (i + 1).ToString("X2"),
                    ClusterName = "Visual Host Servers",
                });

                var serverLog = new ServerLog
                {
                    Server = ravenDbServer,
                    Dock   = DockStyle.Fill,
                    Url    = ravenDbServer.Server.Configuration.ServerUrl
                };
                ServerTabs.TabPages.Add(serverLog.Url);
                var tabPage = ServerTabs.TabPages[ServerTabs.TabPages.Count - 1];
                tabPage.Tag = serverLog;
                ravenDbServer.Server.BeforeDispatchingRequest = context =>
                {
                    var adaptHttpContext = AdaptHttpContext(context, serverLog);
                    if (adaptHttpContext != null)
                    {
                        var increment = serverLog.IncrementRequest();
                        BeginInvoke((Action)(() =>
                        {
                            tabPage.Text = string.Format("{0} ({1})", serverLog.Url, increment);
                        }));
                    }

                    return(adaptHttpContext);
                };
                servers.Add(ravenDbServer);

                tabPage.Controls.Add(serverLog);
            }
        }
Esempio n. 4
0
        private Action AdaptHttpContext(IHttpContext httpContext, ServerLog serverLog)
        {
            if (pathsToFilter.Contains(httpContext.Request.Url.AbsolutePath))
            {
                return(null);
            }
            if (ignoreHilo && httpContext.Request.Url.AbsolutePath.StartsWith("/docs/Raven/Hilo/"))
            {
                return(null);
            }
            if (httpContext.Request.Headers["Raven-Timer-Request"] != null)
            {
                return(null);
            }

            var requestStream = new MemoryStream();

            httpContext.SetRequestFilter(stream =>
            {
                stream.CopyTo(requestStream);
                return(new MemoryStream(requestStream.ToArray()));
            });
            var responseStream = new MemoryStream();

            httpContext.SetResponseFilter(stream => new MultiStreamWriter(responseStream, stream));

            var trackedRequest = new TrackedRequest
            {
                Method          = httpContext.Request.HttpMethod,
                Url             = httpContext.Request.RawUrl,
                RequestHeaders  = new NameValueCollection(httpContext.Request.Headers),
                RequestContent  = requestStream,
                ResponseContent = responseStream,
                ResponseHeaders = httpContext.Response.GetHeaders(),
            };

            return(() =>
            {
                trackedRequest.Status = httpContext.Response.StatusCode;
                serverLog.AddRequest(trackedRequest);
            });
        }
Esempio n. 5
0
		private void StartServers_Click(object sender, EventArgs e)
		{
			Reset();

			for (int i = 0; i < NumberOfServers.Value; i++)
			{
				var ravenDbServer = new RavenDbServer(new RavenConfiguration
				{
					Port = 8079 - i,
					RunInMemory = true,
					AnonymousUserAccessMode = AnonymousUserAccessMode.All
				});

				var serverLog = new ServerLog
				{
					Server = ravenDbServer,
					Dock = DockStyle.Fill,
					Url = ravenDbServer.Server.Configuration.ServerUrl
				};
				ServerTabs.TabPages.Add(serverLog.Url);
				var tabPage = ServerTabs.TabPages[ServerTabs.TabPages.Count - 1];
				tabPage.Tag = serverLog;
				ravenDbServer.Server.BeforeDispatchingRequest = context =>
				{
					var adaptHttpContext = AdaptHttpContext(context, serverLog);
					if (adaptHttpContext != null)
					{
						var increment = Interlocked.Increment(ref serverLog.NumOfRequests);
						BeginInvoke((Action) (() =>
						{
							tabPage.Text = string.Format("{0} ({1})", serverLog.Url, increment);
						}));
					}

					return adaptHttpContext;
				};
				servers.Add(ravenDbServer);

				tabPage.Controls.Add(serverLog);
			}
		}
Esempio n. 6
0
        private void StartServers_Click(object sender, EventArgs e)
        {
            Reset();

            for (int i = 0; i < NumberOfServers.Value; i++)
            {
                var ravenDbServer = new RavenDbServer(new RavenConfiguration
                {
                    Port                    = 8079 - i,
                    RunInMemory             = true,
                    AnonymousUserAccessMode = AnonymousUserAccessMode.All
                });

                var serverLog = new ServerLog
                {
                    Server = ravenDbServer,
                    Dock   = DockStyle.Fill,
                    Url    = ravenDbServer.Server.Configuration.ServerUrl
                };
                ServerTabs.TabPages.Add(serverLog.Url);
                var tabPage = ServerTabs.TabPages[ServerTabs.TabPages.Count - 1];
                tabPage.Tag = serverLog;
                ravenDbServer.Server.BeforeDispatchingRequest = context =>
                {
                    var adaptHttpContext = AdaptHttpContext(context, serverLog);
                    if (adaptHttpContext != null)
                    {
                        var increment = Interlocked.Increment(ref serverLog.NumOfRequests);
                        BeginInvoke((Action)(() =>
                        {
                            tabPage.Text = string.Format("{0} ({1})", serverLog.Url, increment);
                        }));
                    }

                    return(adaptHttpContext);
                };
                servers.Add(ravenDbServer);

                tabPage.Controls.Add(serverLog);
            }
        }