private async Task SendRequestAsync(HttpRequest request, Stream requestStream) { // Headers are always ASCII per the HTTP spec using (var writer = new StreamWriter(requestStream, Encoding.ASCII, bufferSize: MaxRequestHeadersBufferSize, leaveOpen: true)) { await DatadogHttpHeaderHelper.WriteLeadingHeaders(request, writer).ConfigureAwait(false); foreach (var header in request.Headers) { await DatadogHttpHeaderHelper.WriteHeader(writer, header).ConfigureAwait(false); } await DatadogHttpHeaderHelper.WriteEndOfHeaders(writer).ConfigureAwait(false); } await request.Content.CopyToAsync(requestStream, null).ConfigureAwait(false); Logger.Debug("Datadog HTTP: Flushing stream."); await requestStream.FlushAsync().ConfigureAwait(false); }
private async Task SendRequestAsync(HttpRequest request, Stream requestStream) { // Headers are always ASCII per the HTTP spec using (var writer = new StreamWriter(requestStream, Encoding.ASCII, bufferSize: MaxRequestHeadersBufferSize, leaveOpen: true)) { await DatadogHttpHeaderHelper.WriteLeadingHeaders(request, writer).ConfigureAwait(false); foreach (var header in request.Headers) { await DatadogHttpHeaderHelper.WriteHeader(writer, header).ConfigureAwait(false); } await DatadogHttpHeaderHelper.WriteEndOfHeaders(writer).ConfigureAwait(false); // Remove (admittedly really small) sync over async occurrence // by forcing a flush so that System.IO.TextWriter.Dispose() does not block await writer.FlushAsync().ConfigureAwait(false); } await request.Content.CopyToAsync(requestStream).ConfigureAwait(false); Logger.Debug("Datadog HTTP: Flushing stream."); await requestStream.FlushAsync().ConfigureAwait(false); }