diff --git a/conn.go b/conn.go index 90a60c3..dee4790 100644 --- a/conn.go +++ b/conn.go @@ -358,6 +358,22 @@ func (c *ClientConn) CreateRequest(req *http.Request) (*http.Response, error) { //return nil, fmt.Errorf("unknown error") } +// CanTakeNewRequest check if the ClientConn can submit a new request +func (c *ClientConn) CanTakeNewRequest() bool { + if c.closed { + return false + } + + if c.err != nil { + return false + } + + if c.streamCount > ((1 << 31) / 2) { + return false + } + return true +} + // ServerConn server connection type ServerConn struct { // Handler handler to handle request