// 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> 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> 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> header in fromHeaders) { toHeaders.TryAddWithoutValidation(header.Key, header.Value); } } } }