ServiceStack.WebHost.Endpoints.Tests.RequestContextTests.Does_return_bare_401_with_AuthRequired_header C# (CSharp) Method

Does_return_bare_401_with_AuthRequired_header() private method

private Does_return_bare_401_with_AuthRequired_header ( ) : void
return void
		public void Does_return_bare_401_with_AuthRequired_header()
		{
			try
			{
				var webRequest = (HttpWebRequest)WebRequest.Create(ListeningOn 
					+ "json/reply/RequestFilter?StatusCode=401"
					+ "&HeaderName=" + HttpHeaders.WwwAuthenticate
					+ "&HeaderValue=" + "Basic realm=\"Auth Required\"".UrlEncode());

				webRequest.GetResponse();

				Assert.Fail("Should throw 401 WebException");
			}
			catch (WebException ex)
			{
				var httpResponse = (HttpWebResponse)ex.Response;
				Assert.That(httpResponse.StatusCode, Is.EqualTo(HttpStatusCode.Unauthorized));

				Assert.That(ex.Response.Headers[HttpHeaders.WwwAuthenticate],
					Is.EqualTo("Basic realm=\"Auth Required\""));
			}
		}