Пример #1
0
 private void OnRequest(object sender, FactoryRequestEventArgs e)
 {
     RequestReceived(this, e);
 }
Пример #2
0
		/// <summary>
		/// A request was received from the parser.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void OnRequest(object sender, FactoryRequestEventArgs e)
		{
			_context = this;
			Response = HttpFactory.Current.Get<IResponse>(this, e.Request);
			_logger.Debug("Received '" + e.Request.Method + " " + e.Request.Uri.PathAndQuery + "' from " +
			              Socket.RemoteEndPoint);

            LastAction = DateTime.Now;
			// keep alive.
			if (e.Request.Connection != null && e.Request.Connection.Type == ConnectionType.KeepAlive)
                Response.Add(new StringHeader("Keep-Alive", "timeout=5, max=" + HTTPContextManager.MAX_KEEPALIVE));

		    Request = e.Request;
            CurrentRequestReceived(this, new RequestEventArgs(this, e.Request, Response));
            RequestReceived(this, new RequestEventArgs(this, e.Request, Response));

            if (Response.Connection.Type == ConnectionType.KeepAlive)
                HTTPContextManager.Register(this);
            RequestCompleted(this, new RequestEventArgs(this, e.Request, Response));
            CurrentRequestCompleted(this, new RequestEventArgs(this, e.Request, Response));
		}
Пример #3
0
 private void OnRequest(object sender, FactoryRequestEventArgs e)
 {
     RequestReceived(this, e);
 }
		/// <summary>
		/// A request was received from the parser.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void OnRequest(object sender, FactoryRequestEventArgs e)
		{
			_context = this;
			var response = HttpFactory.Current.Get<IResponse>(this, e.Request);
			_logger.Debug("Received '" + e.Request.Method + " " + e.Request.Uri.PathAndQuery + "' from " +
			              Socket.RemoteEndPoint);

			// keep alive.
			if (e.Request.Connection != null && e.Request.Connection.Type == ConnectionType.KeepAlive)
			{
				response.Add(new StringHeader("Keep-Alive", "timeout=5, max=100"));

				// refresh timer
				if (_keepAlive != null)
					_keepAlive.Change(_keepAliveTimeout, _keepAliveTimeout);
			}

			CurrentRequestReceived(this, new RequestEventArgs(this, e.Request, response));
			RequestReceived(this, new RequestEventArgs(this, e.Request, response));

			//
			if (response.Connection.Type == ConnectionType.KeepAlive)
			{
				if (_keepAlive == null)
					_keepAlive = new Timer(OnConnectionTimeout, null, _keepAliveTimeout, _keepAliveTimeout);
			}

			RequestCompleted(this, new RequestEventArgs(this, e.Request, response));
			CurrentRequestCompleted(this, new RequestEventArgs(this, e.Request, response));
		}