Пример #1
0
 async Task <HttpContent> ReadBody(HttpMessage message, CancellationToken cancellationToken)
 {
     TestContext.LogDebug(5, "READ BODY: {0}", message);
     using (var reader = new HttpStreamReader(Context.Request.InputStream)) {
         cancellationToken.ThrowIfCancellationRequested();
         if (message.ContentType != null && message.ContentType.Equals("application/octet-stream"))
         {
             return(await BinaryContent.Read(reader, message.ContentLength.Value, cancellationToken));
         }
         if (message.ContentLength != null)
         {
             return(await StringContent.Read(reader, message.ContentLength.Value, cancellationToken));
         }
         if (message.TransferEncoding != null)
         {
             if (!message.TransferEncoding.Equals("chunked"))
             {
                 throw new InvalidOperationException();
             }
             return(await ChunkedContent.ReadNonChunked(reader, cancellationToken));
         }
         return(null);
     }
 }