diff --git a/cmd/http/bufconn.go b/cmd/http/bufconn.go index c57a68337..f51d25ab3 100644 --- a/cmd/http/bufconn.go +++ b/cmd/http/bufconn.go @@ -99,10 +99,10 @@ func (c *BufConn) Write(b []byte) (n int, err error) { } // newBufConn - creates a new connection object wrapping net.Conn. -func newBufConn(c net.Conn, readTimeout, writeTimeout time.Duration) *BufConn { +func newBufConn(c net.Conn, readTimeout, writeTimeout time.Duration, maxHeaderBytes int) *BufConn { return &BufConn{ QuirkConn: QuirkConn{Conn: c}, - bufReader: bufio.NewReader(c), + bufReader: bufio.NewReaderSize(c, maxHeaderBytes), readTimeout: readTimeout, writeTimeout: writeTimeout, } diff --git a/cmd/http/bufconn_test.go b/cmd/http/bufconn_test.go index f64b0985e..b2b6b609c 100644 --- a/cmd/http/bufconn_test.go +++ b/cmd/http/bufconn_test.go @@ -49,7 +49,7 @@ func TestBuffConnReadTimeout(t *testing.T) { t.Errorf("failed to accept new connection. %v", terr) return } - bufconn := newBufConn(tcpConn, 1*time.Second, 1*time.Second) + bufconn := newBufConn(tcpConn, 1*time.Second, 1*time.Second, 4096) defer bufconn.Close() // Read a line diff --git a/cmd/http/listener.go b/cmd/http/listener.go index 9af8b3815..abbd3752f 100644 --- a/cmd/http/listener.go +++ b/cmd/http/listener.go @@ -222,7 +222,7 @@ func (listener *httpListener) start() { tcpConn.SetKeepAlive(true) tcpConn.SetKeepAlivePeriod(listener.tcpKeepAliveTimeout) - bufconn := newBufConn(tcpConn, listener.readTimeout, listener.writeTimeout) + bufconn := newBufConn(tcpConn, listener.readTimeout, listener.writeTimeout, listener.maxHeaderBytes) if listener.tlsConfig != nil { ok, err := getPlainText(bufconn) if err != nil { @@ -261,7 +261,7 @@ func (listener *httpListener) start() { return } - bufconn = newBufConn(tlsConn, listener.readTimeout, listener.writeTimeout) + bufconn = newBufConn(tlsConn, listener.readTimeout, listener.writeTimeout, listener.maxHeaderBytes) } method, resource, host, err := getMethodResourceHost(bufconn, listener.maxHeaderBytes)