|
|
@@ -43,8 +43,12 @@ namespace IvfTl.ControlHost.Tests
|
|
|
Assert.Contains("--frame", head);
|
|
|
Assert.Contains("Content-Type: image/jpeg", head);
|
|
|
Assert.Contains("Content-Length: 6", head);
|
|
|
- // 帧尾部含 jpeg 原始字节 + 末尾 \r\n
|
|
|
- Assert.Equal(0xFF, frame[frame.Length - 8]); // jpeg 起点附近(粗校验帧体存在)
|
|
|
+ // 帧体起点 = header 长度;尾部是 \r\n
|
|
|
+ string headerStr = "--frame\r\nContent-Type: image/jpeg\r\nContent-Length: 6\r\n\r\n";
|
|
|
+ int bodyStart = System.Text.Encoding.ASCII.GetByteCount(headerStr);
|
|
|
+ var body = new byte[jpeg.Length];
|
|
|
+ System.Array.Copy(frame, bodyStart, body, 0, jpeg.Length);
|
|
|
+ Assert.Equal(jpeg, body); // 帧体整段 == 原 jpeg
|
|
|
Assert.Equal((byte)'\r', frame[frame.Length - 2]);
|
|
|
Assert.Equal((byte)'\n', frame[frame.Length - 1]);
|
|
|
}
|