Esempio n. 1
0
        void OnInputDataReceived(Request sender, DataReceivedArgs args)
        {
            // If the data is completed, call the worker and return.
            if (args.DataCompleted)
            {
                DataNeeded = false;

                if (input_data != null &&
                    write_index < input_data.Length)
                {
                    Abort(Strings.ResponderRequest_IncompleteInput,
                          write_index, input_data.Length);
                }
                else if (Server.MultiplexConnections)
                {
                    ThreadPool.QueueUserWorkItem(Worker);
                }
                else
                {
                    Worker(null);
                }

                return;
            }

            // If input_data is null, create the new array by
            // reading the length from the CONTENT_LENGTH parameter.
            if (input_data == null)
            {
                string length_text = GetParameter("CONTENT_LENGTH");

                // If the field is missing we can't continue.
                if (length_text == null)
                {
                    Abort(Strings.ResponderRequest_NoContentLength);
                    return;
                }

                // If the length isn't a number, we can't
                // continue.
                int length;
                if (!Int32.TryParse(length_text, NumberStyles.Integer,
                                    CultureInfo.InvariantCulture, out length))
                {
                    Abort(Strings.ResponderRequest_NoContentLengthNotNumber);
                    return;
                }

                input_data = new byte [length];
            }

            if (write_index + args.DataLength > input_data.Length)
            {
                Abort(Strings.ResponderRequest_ContentExceedsLength);
                return;
            }

            args.CopyTo(input_data, write_index);
            write_index += args.DataLength;
        }
Esempio n. 2
0
		void OnInputDataReceived (Request sender, DataReceivedArgs args)
		{
			// If the data is completed, call the worker and return.
			if (args.DataCompleted) {
				DataNeeded = false;
				
				if (input_data != null &&
					write_index < input_data.Length) {
					Abort (Strings.ResponderRequest_IncompleteInput,
						write_index, input_data.Length);
				}
				else if (Server.MultiplexConnections)
					ThreadPool.QueueUserWorkItem (Worker);
				else
					Worker (null);
				
				return;
			}
			
			// If input_data is null, create the new array by
			// reading the length from the CONTENT_LENGTH parameter.
			if (input_data == null) {
				string length_text = GetParameter ("CONTENT_LENGTH");
				
				// If the field is missing we can't continue.
				if (length_text == null) {
					Abort (Strings.ResponderRequest_NoContentLength);
					return;
				}
				
				// If the length isn't a number, we can't
				// continue.
				int length;
				if(!Int32.TryParse (length_text, NumberStyles.Integer,
					CultureInfo.InvariantCulture, out length)){
					Abort (Strings.ResponderRequest_NoContentLengthNotNumber);
					return;
				}
				
				input_data = new byte [length];
			}
			
			if (write_index + args.DataLength > input_data.Length)
			{
				Abort (Strings.ResponderRequest_ContentExceedsLength);
				return;
			}
			
			args.CopyTo (input_data, write_index);
			write_index += args.DataLength;
		}