mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
Issue #15: make sure that io.EOF isn't returned on incomplete request/response
This commit is contained in:
@@ -21,6 +21,16 @@ func TestRequestHeaderReadEOF(t *testing.T) {
|
||||
if err != io.EOF {
|
||||
t.Fatalf("unexpected error: %s. Expecting %s", err, io.EOF)
|
||||
}
|
||||
|
||||
// incomplete request header mustn't return io.EOF
|
||||
br = bufio.NewReader(bytes.NewBufferString("GET "))
|
||||
err = r.Read(br)
|
||||
if err == nil {
|
||||
t.Fatalf("expecting error")
|
||||
}
|
||||
if err == io.EOF {
|
||||
t.Fatalf("expecting non-EOF error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResponseHeaderReadEOF(t *testing.T) {
|
||||
@@ -34,6 +44,16 @@ func TestResponseHeaderReadEOF(t *testing.T) {
|
||||
if err != io.EOF {
|
||||
t.Fatalf("unexpected error: %s. Expecting %s", err, io.EOF)
|
||||
}
|
||||
|
||||
// incomplete response header mustn't return io.EOF
|
||||
br = bufio.NewReader(bytes.NewBufferString("HTTP/1.1 "))
|
||||
err = r.Read(br)
|
||||
if err == nil {
|
||||
t.Fatalf("expecting error")
|
||||
}
|
||||
if err == io.EOF {
|
||||
t.Fatalf("expecting non-EOF error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResponseHeaderOldVersion(t *testing.T) {
|
||||
|
||||
@@ -22,6 +22,16 @@ func TestRequestReadEOF(t *testing.T) {
|
||||
if err != io.EOF {
|
||||
t.Fatalf("unexpected error: %s. Expecting %s", err, io.EOF)
|
||||
}
|
||||
|
||||
// incomplete request mustn't return io.EOF
|
||||
br = bufio.NewReader(bytes.NewBufferString("POST / HTTP/1.1\r\nContent-Type: aa\r\nContent-Length: 1234\r\n\r\nIncomplete body"))
|
||||
err = r.Read(br)
|
||||
if err == nil {
|
||||
t.Fatalf("expecting error")
|
||||
}
|
||||
if err == io.EOF {
|
||||
t.Fatalf("expecting non-EOF error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResponseReadEOF(t *testing.T) {
|
||||
@@ -35,6 +45,16 @@ func TestResponseReadEOF(t *testing.T) {
|
||||
if err != io.EOF {
|
||||
t.Fatalf("unexpected error: %s. Expecting %s", err, io.EOF)
|
||||
}
|
||||
|
||||
// incomplete response mustn't return io.EOF
|
||||
br = bufio.NewReader(bytes.NewBufferString("HTTP/1.1 200 OK\r\nContent-Type: aaa\r\nContent-Length: 123\r\n\r\nIncomplete body"))
|
||||
err = r.Read(br)
|
||||
if err == nil {
|
||||
t.Fatalf("expecting error")
|
||||
}
|
||||
if err == io.EOF {
|
||||
t.Fatalf("expecting non-EOF error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResponseWriteTo(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user