This commit is contained in:
2025-10-19 13:28:13 +07:00
12 changed files with 149 additions and 98 deletions
+8 -5
View File
@@ -5,17 +5,20 @@ import (
"strings"
"testing"
"git.3crabs.ru/VLADIMIR/net/url"
"github.com/stretchr/testify/assert"
)
func Test_WriteRequest(t *testing.T) {
b := &strings.Builder{}
writeRequest(
WriteRequest(
b,
&Request{
Method: "GET",
Path: "/",
Method: "GET",
URL: &url.URL{
Path: "/",
},
Protocol: "HTTP/1.0",
},
)
@@ -28,10 +31,10 @@ func Test_ReadResponse(t *testing.T) {
[]byte("HTTP/1.1 200 OK\r\nDate: Sat, 03 Feb 2024 16:40:29 GMT\r\nContent-Length: 12\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nHello World!"),
)
r, err := readResponse(b)
r, err := ReadResponse(b)
assert.Nil(t, err)
assert.Equal(t, 200, r.StatusCode)
assert.Equal(t, "200", r.StatusCode)
assert.Equal(t, "Date", r.Headers[0].Name)
assert.Equal(t, "Sat, 03 Feb 2024 16:40:29 GMT", r.Headers[0].Value)