sse
sse copied to clipboard
Connection leaks if the statusCode not equals with 200
Description
When I subscribes to a server, and it's returns me with status code 401, from the code we can see the req.Body
didn't closed properly.
Workaround
Use a custom ResponseValidator
like below can avoid at user side:
sseClient.ResponseValidator = func(c *sse.Client, resp *http.Response) error {
if resp.StatusCode != 200 {
resp.Body.Close()
return fmt.Errorf("could not connect to stream: %s", http.StatusText(resp.StatusCode))
}
return nil
}
Hi @tigerlee
Thanks for raising the issue! This should now be fixed in v2.3.6
should this issue be closed then?