Support x/h2 v0.2.0 deadline

This commit is contained in:
世界 2022-11-11 22:08:20 +08:00
parent 2c9d25e853
commit ce1ddc400f
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
2 changed files with 42 additions and 6 deletions

View file

@ -153,13 +153,31 @@ func (c *GunConn) RemoteAddr() net.Addr {
} }
func (c *GunConn) SetDeadline(t time.Time) error { func (c *GunConn) SetDeadline(t time.Time) error {
responseWriter, loaded := c.writer.(interface {
SetWriteDeadline(time.Time) error
})
if !loaded {
return os.ErrInvalid return os.ErrInvalid
} }
return responseWriter.SetWriteDeadline(t)
}
func (c *GunConn) SetReadDeadline(t time.Time) error { func (c *GunConn) SetReadDeadline(t time.Time) error {
responseWriter, loaded := c.writer.(interface {
SetReadDeadline(time.Time) error
})
if !loaded {
return os.ErrInvalid return os.ErrInvalid
} }
return responseWriter.SetReadDeadline(t)
}
func (c *GunConn) SetWriteDeadline(t time.Time) error { func (c *GunConn) SetWriteDeadline(t time.Time) error {
responseWriter, loaded := c.writer.(interface {
SetWriteDeadline(time.Time) error
})
if !loaded {
return os.ErrInvalid return os.ErrInvalid
} }
return responseWriter.SetWriteDeadline(t)
}

View file

@ -67,16 +67,34 @@ func (c *HTTPConn) RemoteAddr() net.Addr {
} }
func (c *HTTPConn) SetDeadline(t time.Time) error { func (c *HTTPConn) SetDeadline(t time.Time) error {
responseWriter, loaded := c.writer.(interface {
SetWriteDeadline(time.Time) error
})
if !loaded {
return os.ErrInvalid return os.ErrInvalid
} }
return responseWriter.SetWriteDeadline(t)
}
func (c *HTTPConn) SetReadDeadline(t time.Time) error { func (c *HTTPConn) SetReadDeadline(t time.Time) error {
responseWriter, loaded := c.writer.(interface {
SetReadDeadline(time.Time) error
})
if !loaded {
return os.ErrInvalid return os.ErrInvalid
} }
return responseWriter.SetReadDeadline(t)
}
func (c *HTTPConn) SetWriteDeadline(t time.Time) error { func (c *HTTPConn) SetWriteDeadline(t time.Time) error {
responseWriter, loaded := c.writer.(interface {
SetWriteDeadline(time.Time) error
})
if !loaded {
return os.ErrInvalid return os.ErrInvalid
} }
return responseWriter.SetWriteDeadline(t)
}
type ServerHTTPConn struct { type ServerHTTPConn struct {
HTTPConn HTTPConn