Inheritance: IResponse
        protected ImmutableResponse(Response response, Action<Response> configurationDelegate = null)
        {
            response.ThrowIfNull("response");

            if (configurationDelegate != null)
            {
                configurationDelegate(response);
            }
            _response = response;
        }
示例#2
0
			public void SetUp()
			{
				Response response = new Response()
					.OK()
					.ApplicationJson()
					.Charset("utf-8")
					.Content("content")
					.ContentEncoding(Encoding.ASCII)
					.Cookie(new HttpCookie("name", "value"))
					.Header("field", "value")
					.HeaderEncoding(Encoding.UTF8);

				response.CachePolicy.ETag("etag");

				_cacheResponse = new CacheResponse(response);
			}
        public Task<ResponseResult> GetResponseAsync(ValidationResult result)
        {
            switch (result)
            {
                case ValidationResult.CookieInvalid:
                case ValidationResult.CookieMissing:
                case ValidationResult.FormFieldMissing:
                case ValidationResult.FormFieldInvalid:
                case ValidationResult.NonceInvalid:
                    Response response = new Response().Unauthorized().TextPlain().Content("Anti-CSRF validation failed.");

                    return ResponseResult.ResponseGenerated(response).AsCompletedTask();
                default:
                    return ResponseResult.ResponseNotGenerated().AsCompletedTask();
            }
        }
示例#4
0
			public void SetUp()
			{
				_httpCachePolicyBase = MockRepository.GenerateMock<HttpCachePolicyBase>();

				_httpResponseBase = MockRepository.GenerateMock<HttpResponseBase>();
				_httpResponseBase.Stub(arg => arg.Cache).Return(_httpCachePolicyBase);
				_httpResponseBase.Stub(arg => arg.Cookies).Return(new HttpCookieCollection());
				_httpResponseBase.Stub(arg => arg.Headers).Return(new NameValueCollection());

				Response response = new Response()
					.OK()
					.ApplicationJson()
					.Charset("utf-8")
					.Content("content")
					.ContentEncoding(Encoding.ASCII)
					.Cookie(new HttpCookie("name", "value"))
					.Header("field", "value")
					.HeaderEncoding(Encoding.UTF8);

				response.CachePolicy.NoClientCaching();

				_cacheResponse = new CacheResponse(response);
				_cacheResponse.WriteResponseAsync(_httpResponseBase).Wait();
			}
			public void SetUp()
			{
				_response = new Response().OK();
				_responseResult = ResponseResult.ResponseGenerated(_response);
			}
 public void SetUp()
 {
     _failedResponse = Response.OK();
     _authenticateResult = AuthenticateResult.AuthenticationFailed(_failedResponse);
 }