/// <summary> /// Appends to the body stream /// </summary> /// <returns>The total amount of bytes added</returns> public int AppendBody(byte[] value, int offset, int count) { if (Header == null) { throw new DriverInternalError("To add a response body you must specify the header"); } if (BodyStream == null) { if (Header.BodyLength <= count) { //There is no need to copy the buffer: Use the inner buffer BodyStream = new MemoryStream(value, offset, this.Header.BodyLength, false, false); return(this.Header.BodyLength); } BodyStream = new ListBackedStream(); } if (BodyStream.Position + count > Header.BodyLength) { count = Header.BodyLength - (int)BodyStream.Position; } BodyStream.Write(value, offset, count); return(count); }
/// <summary> /// Write a section of a byte array into the message body, without encoding or interpretation. /// </summary> public IMessageBuilder RawWrite(byte[] bytes, int offset, int length) { BodyStream.Write(bytes, offset, length); return(this); }
public override void Write(byte[] buffer, int offset, int count) { BodyStream.Write(buffer, offset, count); }