public static async Task Post(Protocol protocol, CancellationToken cancelToken) { using (log.Timing("HTTP Call for metrics batch")) using (var client = new HttpClient()) { client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", protocol.UserAgent); log.Debug("URL: {0}", protocol.Url); log.Debug("With headers:{0}{1}", Environment.NewLine, string.Join(Environment.NewLine, client.DefaultRequestHeaders.Select(h => string.Format("{0}: {1}", h.Key, string.Join(",", h.Value))))); await Task.WhenAll(protocol.HitGroups.Select(hitGroup => PostAndLogAsync(client, protocol.Url, hitGroup.ToString(), cancelToken))); } }
public static async Task Post(Protocol protocol) { await Post(protocol, CancellationToken.None); }