private static void ReplaceAppToken(this System.Net.Http.Headers.HttpRequestHeaders headers)
        {
            const string name = "X-App-Token";

            _ = headers.Remove(name);
            headers.Add(name, GetCoolapkAppToken());
        }
        private static void ReplaceRequested(this System.Net.Http.Headers.HttpRequestHeaders headers, string request)
        {
            const string name = "X-Requested-With";

            _ = headers.Remove(name);
            if (request != null)
            {
                headers.Add(name, request);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Copies headers from one <see cref="System.Net.Http.HttpRequestMessage"/> instance to another.
        /// </summary>
        /// <param name="source">The source <see cref="System.Net.Http.HttpRequestMessage"/> to copy from.</param>
        /// <param name="destination">The destination <see cref="System.Net.Http.HttpRequestMessage"/> to copy to.</param>
        public static void CopyHeadersTo(this System.Net.Http.Headers.HttpRequestHeaders source, System.Net.Http.Headers.HttpRequestHeaders destination)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            foreach (var header in source)
            {
                if (destination.Contains(header.Key))
                {
                    destination.Remove(header.Key);
                }

                destination.Add(header.Key, header.Value);
            }
        }