From 8e2d520ba2966517f9c339e36dd89fd8a4460446 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Sun, 9 Apr 2023 20:19:30 +0200 Subject: [PATCH] test: replace net/http internals with bufio --- server_test.go | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/server_test.go b/server_test.go index 42cf002..1f93721 100644 --- a/server_test.go +++ b/server_test.go @@ -17,9 +17,9 @@ import ( "strings" "sync/atomic" "testing" - _ "unsafe" // for go:linkname "github.com/gobwas/httphead" + "github.com/gobwas/pool/pbufio" ) // TODO(gobwas): upgradeGenericCase with methods like configureUpgrader, @@ -700,18 +700,6 @@ func sortHeaders(bts []byte) []byte { return bytes.Join(lines, []byte("\r\n")) } -//go:linkname httpPutBufioReader net/http.putBufioReader -func httpPutBufioReader(*bufio.Reader) - -//go:linkname httpPutBufioWriter net/http.putBufioWriter -func httpPutBufioWriter(*bufio.Writer) - -//go:linkname httpNewBufioReader net/http.newBufioReader -func httpNewBufioReader(io.Reader) *bufio.Reader - -//go:linkname httpNewBufioWriterSize net/http.newBufioWriterSize -func httpNewBufioWriterSize(io.Writer, int) *bufio.Writer - type recorder struct { *httptest.ResponseRecorder hijacked bool @@ -764,10 +752,8 @@ func (r *recorder) Hijack() (conn net.Conn, brw *bufio.ReadWriter, err error) { } } - // Use httpNewBufio* linked functions here to make - // benchmark more closer to real life usage. - br := httpNewBufioReader(conn) - bw := httpNewBufioWriterSize(conn, 4<<10) + br := pbufio.GetReader(conn, DefaultClientReadBufferSize) + bw := pbufio.GetWriter(conn, DefaultClientWriteBufferSize) brw = bufio.NewReadWriter(br, bw)