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

Question: Do I need to close/release connection after using fasthttp.Get() method? #362

Closed
wanghongfei opened this issue Aug 11, 2018 · 2 comments

Comments

@wanghongfei
Copy link

It seems that fasthttp doesn't provide any resource cleaning method for its http client:

_, buf, _ := fasthttp.Get(make([]byte, 100), "http://www.google.com")

So do I need to worry about resource leaking problem? How dose fasthttp manage http connections?

Thanks!

@erikdubbelboer
Copy link
Collaborator

You don't have to worry about the body returned (it will be garbage collected by Go). The connection to the website can stay alive for the keep-alive duration if the connection supports it.

fasthttp.Get is just a shorthand for defaultClient.Get where defaultClient is just a default fasthttp.Client struct.

If you want more control you can make your own fasthttp.Client with different settings and use the Get method on that.

@wanghongfei
Copy link
Author

Thanks for your answer!

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

2 participants