internal static Datagram ParseBody(byte[] buffer, int offset, int length, bool isBodyPossible, HttpHeader header)
        {
            if (!isBodyPossible)
            {
                return(Datagram.Empty);
            }
            HttpTransferEncodingField transferEncoding = header.TransferEncoding;

            if (transferEncoding != null && transferEncoding.TransferCodings != null && Enumerable.Any <string>((IEnumerable <string>)transferEncoding.TransferCodings, (Func <string, bool>)(coding => coding != "identity")))
            {
                return(HttpDatagram.ParseChunkedBody(buffer, offset, length));
            }
            HttpContentLengthField contentLength1 = header.ContentLength;

            if (contentLength1 != null)
            {
                uint?contentLength2 = contentLength1.ContentLength;
                if (contentLength2.HasValue)
                {
                    return(new Datagram(buffer, offset, Math.Min((int)contentLength2.Value, length)));
                }
            }
            HttpContentTypeField contentType = header.ContentType;

            if (contentType != null && contentType.MediaType == "multipart" && contentType.MediaSubtype == "byteranges")
            {
                string str = contentType.Parameters["boundary"];
                if (str != null)
                {
                    byte[] bytes = Encoding.ASCII.GetBytes(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "\r\n--{0}--", new object[1]
                    {
                        (object)str
                    }));
                    int num = ByteArrayExtensions.Find(buffer, offset, length, bytes) + bytes.Length;
                    return(new Datagram(buffer, offset, Math.Min(num - offset, length)));
                }
            }
            return(new Datagram(buffer, offset, length));
        }
 public void ByteArrayFindNullArrayTest()
 {
     Assert.IsNotNull(ByteArrayExtensions.Find(null, 1, 1, new byte[1]));
     Assert.Fail();
 }