Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection leaks if the statusCode not equals with 200 #95

Open
tigerlee opened this issue Sep 2, 2021 · 2 comments
Open

Connection leaks if the statusCode not equals with 200 #95

tigerlee opened this issue Sep 2, 2021 · 2 comments

Comments

@tigerlee
Copy link
Contributor

tigerlee commented Sep 2, 2021

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
}
@purehyperbole
Copy link
Member

Hi @tigerlee

Thanks for raising the issue! This should now be fixed in v2.3.6

@ss89
Copy link

ss89 commented Apr 24, 2022

should this issue be closed then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants