tests passing babyyyyy, header is 112 bytes of pure ecstasy

This commit is contained in:
soypat
2025-05-25 02:01:53 -03:00
parent 095c4e1b57
commit b63ce5a964
3 changed files with 87 additions and 86 deletions
+33
View File
@@ -0,0 +1,33 @@
package httpx
import (
"bytes"
"net/http"
"strings"
"testing"
)
func TestHeaderParseRequest(t *testing.T) {
const (
wantMethod = "GET"
wantURI = "/"
wantMessage = "hello world!"
)
req, err := http.NewRequest(wantMethod, wantURI, strings.NewReader(wantMessage))
if err != nil {
t.Fatal(err)
}
var buf bytes.Buffer
req.Write(&buf)
var hdr header
err = hdr.ParseBytes(buf.Bytes())
if err != nil {
t.Fatal(err)
}
if !hdr.MethodIs(wantMethod) {
t.Errorf("want method %s, got %q", wantMethod, hdr.Method())
}
if !bytes.Equal(hdr.RequestURI(), []byte(wantURI)) {
t.Errorf("want request URI %q, got %q", wantURI, hdr.RequestURI())
}
}