Beispiel #1
0
        protected override HttpResponseMetadata CreateResponseMetadata()
        {
            var builder = new HttpResponseMetadataBuilder(HttpStatusCode.NotFound);

            builder.Headers.SetContentLength(0);
            return(builder.Build());
        }
        protected override HttpResponseMetadata TransformMetadata(HttpResponseMetadata metadata)
        {
            if (metadata.Line.Code == HttpStatusCode.Found)
            {
                var location = metadata.Headers.GetLocation();

                var locationIsAbsolute = location.StartsWith("http://") || location.StartsWith("https://");
                if (locationIsAbsolute)
                {
                    var uri = new Uri(location);

                    if (
                        uri.Authority == _domesticAuthority ||
                        uri.Authority == _domesticAuthorityWithPort)
                    {
                        var changedLocation = this.BuildExternalUrl(uri.PathAndQuery);

                        var responseMetadataBuilder = new HttpResponseMetadataBuilder(metadata);
                        responseMetadataBuilder.Headers.Replace("Location", changedLocation);

                        metadata = responseMetadataBuilder.Build();
                    }
                }
            }

            return(metadata);
        }
Beispiel #3
0
        protected override HttpResponseMetadata CreateResponseMetadata()
        {
            var builder = new HttpResponseMetadataBuilder(HttpStatusCode.OK);

            builder.Headers
            .SetContentType(this.ContentType)
            .SetContentLength(this.Content.Length);

            return(builder.Build());
        }