private static Dictionary <string, string> GetHeaders(HttpContentHeaders headers) { var output = new Dictionary <string, string>(); foreach (var item in headers.ToList()) { output.Add(item.Key, headers.GetValues(item.Key).First().ToString()); } return(output); }
private string SerializeHeaders(HttpContentHeaders headers) { var dict = new Dictionary <string, string>(); foreach (var item in headers.ToList()) { if (item.Value != null) { var header = String.Empty; foreach (var value in item.Value) { header += value + " "; } // Trim the trailing space and add item to the dictionary header = header.TrimEnd(" ".ToCharArray()); dict.Add(item.Key, header); } } return(JsonConvert.SerializeObject(dict, Newtonsoft.Json.Formatting.Indented)); }