private static RpcHttp ToRpcHttp()

in src/Utility/TypeExtensions.cs [172:201]


        private static RpcHttp ToRpcHttp(this HttpResponseContext httpResponseContext)
        {
            var rpcHttp = new RpcHttp
            {
                StatusCode = httpResponseContext.StatusCode.ToString("d")
            };

            rpcHttp.Body = httpResponseContext.Body == null
                            ? string.Empty.ToTypedData()
                            : httpResponseContext.Body.ToTypedData();

            rpcHttp.EnableContentNegotiation = httpResponseContext.EnableContentNegotiation;

            // Add all the headers. ContentType is separated for convenience
            if (httpResponseContext.Headers != null)
            {
                foreach (DictionaryEntry item in httpResponseContext.Headers)
                {
                    rpcHttp.Headers.Add(item.Key.ToString(), item.Value.ToString());
                }
            }

            // Allow the user to set content-type in the Headers
            if (!rpcHttp.Headers.ContainsKey(ContentTypeHeaderKey))
            {
                rpcHttp.Headers.Add(ContentTypeHeaderKey, DeriveContentType(httpResponseContext, rpcHttp));
            }

            return rpcHttp;
        }