Compare commits

..
Author SHA1 Message Date
Fangliding 87bd03816a TLS handshake timeout 2026-11-16 08:43:03 +08:00
3 changed files with 14 additions and 3 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ func (h *HunkReaderWriter) ReadMultiBuffer() (buf.MultiBuffer, error) {
}
}
if len(h.buf) == buf.Size {
if cap(h.buf) >= buf.Size {
b := h.buf
h.index = len(h.buf)
return buf.MultiBuffer{buf.NewExisted(b)}, nil
@@ -74,10 +74,14 @@ func (h *MultiHunkReaderWriter) ReadMultiBuffer() (buf.MultiBuffer, error) {
continue
}
if len(b) == buf.Size {
if cap(b) >= buf.Size {
mb = append(mb, buf.NewExisted(b))
} else {
mb = buf.MergeBytes(mb, b)
nb := buf.New()
nb.Extend(int32(len(b)))
copy(nb.Bytes(), b)
mb = append(mb, nb)
}
}
+7
View File
@@ -103,6 +103,13 @@ func (c *UConn) Close() error {
return c.Conn.Close()
}
func (c *UConn) HandshakeContext(ctx context.Context) error {
// Chrome の default handshake timeout
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
return c.UConn.HandshakeContext(ctx)
}
func (c *UConn) HandshakeContextServerName(ctx context.Context) string {
if err := c.HandshakeContext(ctx); err != nil {
return ""