コード例 #1
0
ファイル: HttpRequest.cs プロジェクト: GotenXiao/blink1
		internal HttpRequest(HttpClient client)
		{
			dataMode = DataMode.Text;
			state = ProcessingState.RequestLine;
			connMode = ConnectionMode.KeepAlive;
			this.client = client;
			response = new HttpResponse(this);
		}
コード例 #2
0
ファイル: ClientEventArgs.cs プロジェクト: GotenXiao/blink1
		internal ResponseEventArgs(HttpClient client, HttpResponse response, long contentLength) : base(client)
		{
			this.response = response;
			this.contentLength = contentLength;
		}
コード例 #3
0
ファイル: ClientEventArgs.cs プロジェクト: GotenXiao/blink1
		internal ResponseEventArgs(HttpClient client, HttpResponse response) : this(client, response, -1)
		{
		}
コード例 #4
0
ファイル: ClientEventArgs.cs プロジェクト: GotenXiao/blink1
		internal RequestEventArgs(HttpClient client, HttpRequest request) : base(client)
		{
			this.request = request;
		}
コード例 #5
0
ファイル: ClientEventArgs.cs プロジェクト: GotenXiao/blink1
		/// <summary>
		/// Creates a new <see cref="ClientEventArgs"/> with the specified client.
		/// </summary>
		/// <param name="client">The client to which the event belongs.</param>
		public ClientEventArgs(HttpClient client)
		{
			this.client = client;
		}
コード例 #6
0
ファイル: HttpServer.cs プロジェクト: GotenXiao/blink1
		internal void OnRequestReceived(HttpClient client, HttpRequest request)
		{
			try
			{
				RequestEventArgs args = new RequestEventArgs(client, request);

				if(RequestReceived != null)
					RequestReceived(this, args);
				if(request.IsValidRequest)
				{
					if(logRequests)
						//BUG: Uri.ToString() decodes a url encoded string for a second time; % disappears
						Log.WriteLine("Request: " + client.RemoteAddress + " " + request.Uri);
					if(ValidRequestReceived != null)
						ValidRequestReceived(this, args);
				}
				else
				{
					if(InvalidRequestReceived != null)
						InvalidRequestReceived(this, args);
				}
			}
			finally
			{
			}
		}
コード例 #7
0
ファイル: HttpServer.cs プロジェクト: GotenXiao/blink1
		void DoListen()
		{
			try
			{

				while(!stop)
				{
					HttpClient client;
					try
					{
						client = new HttpClient(listener.AcceptSocket(), this);
					}
					catch(IOException)
					{
						continue;
					}
					catch(SocketException)
					{
						continue;
					}
					client.Disconnected += new EventHandler(client_Disconnected);
					if(ClientConnected != null)
						ClientConnected(this, new ClientEventArgs(client));
					if(logConnections)
						Log.WriteLine("Connected: " + client.RemoteAddress);
				}
			}
#if !DEBUG
			catch(SocketException e)
			{
				Log.WriteLine("Error: " + e.ToString());
			}
#endif
			finally
			{
				stop = false;
				listener.Stop();
				listener = null;
				isRunning = false;
			}
		}