private async static Task <IReadOnlyList <CloudEvent> > ToCloudEventBatchInternalAsync(HttpListenerRequest httpListenerRequest, CloudEventFormatter formatter, IEnumerable <CloudEventAttribute>?extensionAttributes, bool async) { Validation.CheckNotNull(httpListenerRequest, nameof(httpListenerRequest)); Validation.CheckNotNull(formatter, nameof(formatter)); if (HasCloudEventsBatchContentType(httpListenerRequest)) { var contentType = MimeUtilities.CreateContentTypeOrNull(httpListenerRequest.ContentType); return(async ? await formatter.DecodeBatchModeMessageAsync(httpListenerRequest.InputStream, contentType, extensionAttributes).ConfigureAwait(false) : formatter.DecodeBatchModeMessage(httpListenerRequest.InputStream, contentType, extensionAttributes)); } else { throw new ArgumentException("HTTP message does not represent a CloudEvents batch.", nameof(httpListenerRequest)); } }