BloggingSystem.IntegrationTests.InMemoryHttpServer.Put C# (CSharp) Method

Put() public method

public Put ( string requestUrl, object data = null, string>.IDictionary headers = null, string mediaType = "application/json" ) : HttpResponseMessage
requestUrl string
data object
headers string>.IDictionary
mediaType string
return System.Net.Http.HttpResponseMessage
        public HttpResponseMessage Put(
            string requestUrl,
            object data = null,
            IDictionary<string, string> headers = null,
            string mediaType = "application/json")
        {
            var url = requestUrl;
            var request = new HttpRequestMessage();
            request.RequestUri = new Uri(baseUrl + url);
            if (data != null)
            {
                request.Content = new StringContent(JsonConvert.SerializeObject(data));
                request.Content.Headers.ContentType = new MediaTypeHeaderValue(mediaType);
            }

            request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(mediaType));
            request.Method = HttpMethod.Put;

            if (headers != null)
            {
                foreach (var header in headers)
                {
                    request.Headers.Add(header.Key, header.Value);
                }
            }

            var response = this.client.SendAsync(request).Result;
            return response;
        }