예제 #1
0
        public static HttpResponseMessage CreateResponseMessage(BaristaContext ctx, BrewResponse response)
        {
            var result = ResponseValueConverter.CreateResponseMessageForValue(ctx, response.Body);

            result.StatusCode   = (HttpStatusCode)response.StatusCode;
            result.ReasonPhrase = response.StatusDescription;
            foreach (var header in response.Headers.AllHeaders)
            {
                result.Headers.Add(header.Key, header.Value);
            }

            if (!string.IsNullOrWhiteSpace(response.ContentType))
            {
                result.Content.Headers.ContentType = new MediaTypeHeaderValue(response.ContentType);
            }

            if (!string.IsNullOrWhiteSpace(response.ContentDisposition))
            {
                result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue(response.ContentDisposition);
            }

            return(result);
        }