Пример #1
0
			public HttpRequestContent (HttpRequestTestRunner runner, HttpRequestRequest request)
			{
				TestRunner = runner;
				Request = request;
				ME = $"{GetType ().Name}({runner.EffectiveType})";

				switch (runner.EffectiveType) {
				case HttpRequestTestType.EntityTooBig:
				case HttpRequestTestType.ClientAbortsPost:
					HasLength = true;
					Length = 16;
					break;
				case HttpRequestTestType.PostContentLength:
					HasLength = true;
					Length = ConnectionHandler.TheQuickBrownFoxBuffer.Length;
					break;
				case HttpRequestTestType.LargeChunkRead:
					break;
				case HttpRequestTestType.GetNoLength:
					NoLength = true;
					break;
				default:
					HasLength = true;
					Length = 4096;
					break;
				}
			}
Пример #2
0
		public HttpRequestHandler (HttpRequestTestRunner parent)
			: base (parent.EffectiveType.ToString ())
		{
			TestRunner = parent;
			ME = $"{GetType ().Name}({parent.EffectiveType})";
			readyTcs = new TaskCompletionSource<bool> ();
			Flags = RequestFlags.KeepAlive;

			switch (parent.EffectiveType) {
			case HttpRequestTestType.LargeHeader:
			case HttpRequestTestType.LargeHeader2:
			case HttpRequestTestType.SendResponseAsBlob:
				Content = ConnectionHandler.TheQuickBrownFoxContent;
				CloseConnection = true;
				break;
			case HttpRequestTestType.CloseRequestStream:
				OperationFlags = HttpOperationFlags.AbortAfterClientExits;
				CloseConnection = false;
				break;
			case HttpRequestTestType.ReadTimeout:
				CloseConnection = false;
				break;
			case HttpRequestTestType.RedirectNoLength:
				Target = new HelloWorldHandler (ME);
				OperationFlags |= HttpOperationFlags.RedirectOnNewConnection;
				CloseConnection = false;
				break;
			case HttpRequestTestType.PutChunked:
			case HttpRequestTestType.PutChunkDontCloseRequest:
				CloseConnection = true;
				break;
			case HttpRequestTestType.ServerAbortsRedirect:
				OperationFlags = HttpOperationFlags.ServerAbortsRedirection;
				CloseConnection = false;
				break;
			case HttpRequestTestType.ServerAbortsPost:
				OperationFlags = HttpOperationFlags.ServerAbortsRedirection;
				CloseConnection = true;
				break;
			case HttpRequestTestType.PostChunked:
				OperationFlags = HttpOperationFlags.DontReadRequestBody;
				CloseConnection = false;
				break;
			case HttpRequestTestType.EntityTooBig:
			case HttpRequestTestType.ClientAbortsPost:
				OperationFlags = HttpOperationFlags.AbortAfterClientExits | HttpOperationFlags.DontReadRequestBody;
				CloseConnection = false;
				break;
			case HttpRequestTestType.PostContentLength:
				OperationFlags = HttpOperationFlags.DontReadRequestBody;
				break;
			case HttpRequestTestType.SimpleGZip:
				Content = HttpContent.TheQuickBrownFox;
				CloseConnection = true;
				break;
			case HttpRequestTestType.TestResponseStream:
				Content = new StringContent ("AAAA");
				CloseConnection = true;
				break;
			case HttpRequestTestType.LargeChunkRead:
				Content = HttpContent.TheQuickBrownFoxChunked;
				ExpectedContent = Content.RemoveTransferEncoding ();
				CloseConnection = false;
				break;
			case HttpRequestTestType.LargeGZipRead:
				Content = ConnectionHandler.GetLargeChunkedContent (16384);
				ExpectedContent = Content.RemoveTransferEncoding ();
				CloseConnection = false;
				break;
			case HttpRequestTestType.GZipWithLength:
				Content = ConnectionHandler.GetLargeStringContent (16384);
				ExpectedContent = Content;
				CloseConnection = false;
				break;
			case HttpRequestTestType.ResponseStreamCheckLength2:
				Content = HttpContent.HelloChunked;
				ExpectedContent = Content.RemoveTransferEncoding ();
				CloseConnection = false;
				break;
			case HttpRequestTestType.ResponseStreamCheckLength:
				Content = HttpContent.HelloWorld;
				ExpectedContent = Content;
				CloseConnection = false;
				break;
			case HttpRequestTestType.GetNoLength:
				ExpectedContent = ConnectionHandler.TheQuickBrownFoxContent;
				CloseConnection = false;
				break;
			case HttpRequestTestType.ImplicitHost:
			case HttpRequestTestType.CustomHost:
			case HttpRequestTestType.CustomHostWithPort:
			case HttpRequestTestType.CustomHostDefaultPort:
				CloseConnection = false;
				break;
			default:
				throw new NotSupportedException (parent.EffectiveType.ToString ());
			}

			if (CloseConnection)
				Flags |= RequestFlags.CloseConnection;

			if (ExpectedContent == null)
				ExpectedContent = Content ?? new StringContent (ME);
		}