Added a check for malformed headers

This commit is contained in:
2025-02-14 22:28:29 +01:00
parent e787609322
commit a4177508f1
3 changed files with 25 additions and 0 deletions

View File

@ -136,6 +136,26 @@ func TestBadRequestProtocol(t *testing.T) {
s.Run(":8080")
}
func TestConnectionClose(t *testing.T) {
s := web.NewServer()
go func() {
defer syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
conn, err := net.Dial("tcp", ":8080")
assert.Nil(t, err)
defer conn.Close()
_, err = io.WriteString(conn, "GET / HTTP/1.1\r\nConnection: close\r\n\r\n")
assert.Nil(t, err)
_, err = io.ReadAll(conn)
assert.Nil(t, err)
}()
s.Run(":8080")
}
func TestEarlyClose(t *testing.T) {
s := web.NewServer()