public int AddToBody(byte[] bytes, int offset, int length)
{
if (bytes == null)
throw new ArgumentNullException("bytes");
if (offset + length > bytes.Length)
throw new ArgumentOutOfRangeException("offset");
if (length == 0)
return 0;
if (!_body.CanWrite)
throw new InvalidOperationException("Body is not writable.");
if (length > _bodyBytesLeft)
{
length = _bodyBytesLeft;
}
_body.Write(bytes, offset, length);
_bodyBytesLeft -= length;
return length;
}