Validate() публичный Метод

public Validate ( ) : void
Результат void
Пример #1
0
            public virtual void ProcessRequests()
            {
                do
                {
                    try
                    {
                        HttpHeaders lHeaders = HttpHeaders.Create(DataConnection);
                        if (lHeaders == null)
                        {
                            DataConnection.Close();                             // disconnected
                            break;
                        }
                        HttpServerRequest lRequest = new HttpServerRequest(DataConnection, lHeaders);

                        /* ToDo: make (some) validation optinal, for speed purposes */
                        if (Owner.ValidateRequests)
                        {
                            lRequest.Validate();
                        }

                        HttpServerResponse lResponse = new HttpServerResponse();
                        lResponse.KeepAlive = (lRequest.KeepAlive && Owner.KeepAlive);
                        lResponse.Header.SetHeaderValue("Server", Owner.ServerName);

                        this.Owner.HandleHttpRequest(DataConnection, lRequest, lResponse);

                        lRequest.FlushContent();

                        lResponse.WriteToConnection(DataConnection);
                        if (!lRequest.KeepAlive || !Owner.KeepAlive)
                        {
                            DataConnection.Close(false);
                        }
                    }
                    catch (HttpRequestInvalidException e)
                    {
                        this.SendError(e.ErrorCode, e);
                    }
                    catch (ConnectionClosedException)
                    {
                        DataConnection.Close(false);
                    }
                    catch (SocketException)
                    {
                        DataConnection.Close(false);
                    }
                    catch (Exception e)
                    {
                        this.SendError(HttpStatusCode.InternalServerError, e);
                    }
                }while (this.DataConnection.Connected);

                DataConnection.Close();
            }
Пример #2
0
        public virtual void ProcessRequests()
        {
            do
            {
                try
                {
                    HttpHeaders lHeaders = HttpHeaders.Create(DataConnection);
                    if (lHeaders == null)
                    {
                        DataConnection.Close(); // disconnected
                        break;
                    }
                    HttpServerRequest lRequest = new HttpServerRequest(DataConnection, lHeaders);

                    /* ToDo: make (some) validation optinal, for speed purposes */
                    if (Owner.ValidateRequests)
                        lRequest.Validate();

                    HttpServerResponse lResponse = new HttpServerResponse();
                    lResponse.KeepAlive = (lRequest.KeepAlive && Owner.KeepAlive);
                    lResponse.Header.SetHeaderValue("Server", Owner.ServerName);

                    Owner.HandleHttpRequest(DataConnection, lRequest, lResponse);

                    lRequest.FlushContent();

                    lResponse.WriteToConnection(DataConnection);
                    if (!lRequest.KeepAlive)
                        DataConnection.Close(false);
                }
                catch (HttpRequestInvalidException e)
                {
                    e.Response.Header.SetHeaderValue("Server", Owner.ServerName);
                    e.Response.WriteToConnection(DataConnection);
                    DataConnection.Close();
                }
                catch (ConnectionClosedException)
                {
                    DataConnection.Close(false);
                }
                catch (SocketException)
                {
                    DataConnection.Close(false);
                }
                catch (Exception e)
                {
                    HttpServerResponse lResponse = new HttpServerResponse();
                    lResponse.Header.SetHeaderValue("Server", Owner.ServerName);
                    lResponse.SendError(500, "Server Error while processing HTTP request.", e);
                    lResponse.WriteToConnection(DataConnection);
                    DataConnection.Close();
                }

                if (!Owner.KeepAlive)
                    DataConnection.Close();
            }
            while (Owner.KeepAlive && DataConnection.Connected);
        }
Пример #3
0
			private void ProcessRequests()
			{
				do
				{
					try
					{
						HttpHeaders lHeaders = HttpHeaders.Create(DataConnection);
						if (lHeaders == null)
						{
							DataConnection.Close(); // disconnected
							break;
						}
						HttpServerRequest lRequest = new HttpServerRequest(DataConnection, lHeaders);

						if (Owner.ValidateRequests)
							lRequest.Validate();

						HttpServerResponse lResponse = new HttpServerResponse();
						lResponse.KeepAlive = (lRequest.KeepAlive && Owner.KeepAlive);
						lResponse.Header.SetHeaderValue("Server", Owner.ServerName);

						this.Owner.HandleHttpRequest(DataConnection, lRequest, lResponse);

						lRequest.FlushContent();

						lResponse.WriteToConnection(DataConnection);
						if (!lRequest.KeepAlive || !this.Owner.KeepAlive)
							this.DataConnection.Close();
					}
					catch (HttpRequestInvalidException e)
					{
						this.SendError(e.ErrorCode, e);
					}
					catch (ConnectionClosedException)
					{
						this.DataConnection.Close();
					}
					catch (SocketException)
					{
						this.DataConnection.Close();
					}
					catch (Exception e)
					{
						this.SendError(HttpStatusCode.InternalServerError, e);
					}
				}
				while (this.DataConnection.Connected);

				this.DataConnection.Close();
			}