//[InlineData("GET /123.html\r\nHost: www.newlifex.com\r\n")] //[InlineData("GET /123.html\r\nHost: www.newlifex.com")] public void ReadGetMessge(String http) { var msg = new HttpMessage(); var rs = msg.Read(http.GetBytes()); Assert.True(rs); rs = msg.ParseHeaders(); Assert.True(rs); Assert.Equal("GET", msg.Method); Assert.Equal("/123.html", msg.Uri); Assert.Equal("www.newlifex.com", msg.Headers["host"]); }
public void ReadPostMessage(String http) { var msg = new HttpMessage(); var rs = msg.Read(http.GetBytes()); Assert.True(rs); rs = msg.ParseHeaders(); Assert.True(rs); Assert.Equal("POST", msg.Method); Assert.Equal("/123.ashx", msg.Uri); Assert.Equal("www.newlifex.com", msg.Headers["host"]); var body = msg.Payload; Assert.NotNull(body); if (body.Total == 9) { var str = body.ToStr(); Assert.Equal("code=abcd", str); Assert.Equal(body.Total, msg.ContentLength); } else { if (msg.Headers.ContainsKey("Content-Length")) { Assert.Equal(body.Total, msg.ContentLength); } else { Assert.Equal(-1, msg.ContentLength); } } }