Files
linux-packaging-mono/external/aspnetwebstack/src/System.Net.Http.Formatting/HttpHeaderExtensions.cs

45 lines
1.7 KiB
C#
Raw Normal View History

// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Net.Http.Headers;
namespace System.Net.Http
{
internal static class HttpHeaderExtensions
{
public static void CopyTo(this HttpContentHeaders fromHeaders, HttpContentHeaders toHeaders)
{
Contract.Assert(fromHeaders != null, "fromHeaders cannot be null.");
Contract.Assert(toHeaders != null, "toHeaders cannot be null.");
foreach (KeyValuePair<string, IEnumerable<string>> header in fromHeaders)
{
toHeaders.TryAddWithoutValidation(header.Key, header.Value);
}
}
public static void CopyTo(this HttpRequestHeaders fromHeaders, HttpRequestHeaders toHeaders)
{
Contract.Assert(fromHeaders != null, "fromHeaders cannot be null.");
Contract.Assert(toHeaders != null, "toHeaders cannot be null.");
foreach (KeyValuePair<string, IEnumerable<string>> header in fromHeaders)
{
toHeaders.TryAddWithoutValidation(header.Key, header.Value);
}
}
public static void CopyTo(this HttpResponseHeaders fromHeaders, HttpResponseHeaders toHeaders)
{
Contract.Assert(fromHeaders != null, "fromHeaders cannot be null.");
Contract.Assert(toHeaders != null, "toHeaders cannot be null.");
foreach (KeyValuePair<string, IEnumerable<string>> header in fromHeaders)
{
toHeaders.TryAddWithoutValidation(header.Key, header.Value);
}
}
}
}