WriteResponseAsync() public method

public WriteResponseAsync ( System.Web.HttpResponseBase response ) : System.Threading.Tasks.Task
response System.Web.HttpResponseBase
return System.Threading.Tasks.Task
示例#1
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();
			}
		private static async Task<ResponseHandlerResult> WriteResponseAsync(HttpResponseBase httpResponse, CacheResponse cacheResponse)
		{
			await cacheResponse.WriteResponseAsync(httpResponse);

			return ResponseHandlerResult.ResponseWritten();
		}