示例#1
0
        public void StatusCode_DefaultsTo200()
        {
            // Arrange & Act
            var responseInformation = new ResponseFeature();

            // Assert
            Assert.Equal(200, responseInformation.StatusCode);
            Assert.False(responseInformation.HeadersSent);

            responseInformation.FireOnSendingHeaders();

            Assert.True(responseInformation.HeadersSent);
        }
        public void StatusCode_DefaultsTo200()
        {
            // Arrange & Act
            var responseInformation = new ResponseFeature();

            // Assert
            Assert.Equal(200, responseInformation.StatusCode);
            Assert.False(responseInformation.HeadersSent);

            responseInformation.FireOnSendingHeaders();

            Assert.True(responseInformation.HeadersSent);
        }
示例#3
0
            internal HttpResponseMessage GenerateResponse()
            {
                _responseFeature.FireOnSendingHeaders();

                var response = new HttpResponseMessage();

                response.StatusCode     = (HttpStatusCode)HttpContext.Response.StatusCode;
                response.ReasonPhrase   = HttpContext.GetFeature <IHttpResponseFeature>().ReasonPhrase;
                response.RequestMessage = _request;
                // response.Version = owinResponse.Protocol;

                response.Content = new StreamContent(_responseStream);

                foreach (var header in HttpContext.Response.Headers)
                {
                    if (!response.Headers.TryAddWithoutValidation(header.Key, header.Value))
                    {
                        bool success = response.Content.Headers.TryAddWithoutValidation(header.Key, header.Value);
                        Contract.Assert(success, "Bad header");
                    }
                }
                return(response);
            }