Beispiel #1
0
        /// <summary>
        /// Creates an <see cref="HttpResponseMessage"/> instance.
        /// </summary>
        /// <param name="requestUri">Request URI.</param>
        /// <param name="content"><see cref="HttpContent"/> instance.</param>
        /// <returns>Returns the <see cref="HttpRequestMessage"/> instance.</returns>
        protected HttpRequestMessage CreateRequest(string requestUri = null, HttpContent content = null)
        {
            var config = new HttpConfiguration()
            {
                Formatters = { new JsonMediaTypeFormatter() }
            };
            var context = new HttpRequestContext()
            {
                Configuration = config
            };
            var request = new HttpRequestMessage()
            {
                Properties = { { HttpPropertyKeys.RequestContextKey, context } }
            };

            if (!requestUri.IsNullOrWhiteSpace())
            {
                request.RequestUri = new Uri(requestUri);
            }

            if (!content.IsNullOrDefault())
            {
                request.Content = content;
            }

            return(request);
        }
Beispiel #2
0
        /// <summary>
        /// Creates an <see cref="HttpResponseMessage"/> instance.
        /// </summary>
        /// <param name="requestUri">Request URI.</param>
        /// <param name="content"><see cref="HttpContent"/> instance.</param>
        /// <returns>Returns the <see cref="HttpRequestMessage"/> instance.</returns>
        protected HttpRequestMessage CreateRequest(string requestUri = null, HttpContent content = null)
        {
            var request = new HttpRequestMessage();

            if (!requestUri.IsNullOrWhiteSpace())
            {
                request.RequestUri = new Uri(requestUri);
            }

            if (!content.IsNullOrDefault())
            {
                request.Content = content;
            }

            return(request);
        }