From 6a45702d8e83973d185136926a313a5868d36e02 Mon Sep 17 00:00:00 2001 From: bddjr Date: Mon, 9 Dec 2024 18:30:30 +0800 Subject: [PATCH] Fix bug --- src_conn.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src_conn.go b/src_conn.go index 754ea75..7496f5a 100644 --- a/src_conn.go +++ b/src_conn.go @@ -14,7 +14,7 @@ var ErrHttpOnHttpsPort = errors.New("client sent an HTTP request to an HTTPS ser type conn struct { net.Conn - tc *tls.Conn + tc *tls.Conn // reading tls if nil srv *Server } @@ -52,7 +52,7 @@ func (c *conn) readRequest(b []byte, n int) (*http.Request, error) { func (c *conn) Read(b []byte) (int, error) { n, err := c.Conn.Read(b) - if err != nil || n <= 0 { + if c.tc == nil || err != nil || n <= 0 { return n, err } @@ -60,6 +60,7 @@ func (c *conn) Read(b []byte) (int, error) { // Not looks like HTTP. // TLS handshake: 0x16 c.setRawConn() + c.tc = nil return n, nil }