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

chore: re-use same instance of reqwest::blocking::Client & add brotli support #650

Merged

Conversation

EverlastingBugstopper
Copy link
Contributor

This change allows us to take advantage of reqwest's ability to re-use connections. Their docs explain that you should reuse a client by cloning it to take advantage of its internal connection pool.

It additionally adds the ability to decrompress any responses that are brotli compressed. I imagine there's at least one GraphQL server out there that will need that capability and the cost of adding support is minimal.

This change allows us to take advantage of reqwest's
ability to re-use connections. Their [docs](https://docs.rs/reqwest/0.11.4/reqwest/blocking/struct.Client.html)
explain that you should reuse a client by cloning it to take advantage of
its internal connection pool.
Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looked good to me!

self.client.clone()
}

pub fn get_authenticated_client(&self, profile_name: &str) -> Result<StudioClient> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a more appropriate name, too!

Comment on lines +8 to +9
.gzip(true)
.brotli(true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for posterity, I wanted to make sure this uses the appropriate headers when determining whether or not it attempts the decompression, and indeed it does according to the docs.

@EverlastingBugstopper EverlastingBugstopper merged commit e9aae3a into avery/fixup-native-roots Jul 2, 2021
@EverlastingBugstopper EverlastingBugstopper deleted the avery/the-one-true-client branch July 2, 2021 16:44
EverlastingBugstopper added a commit that referenced this pull request Jul 2, 2021
…li support (#650)

This change allows us to take advantage of reqwest's
ability to re-use connections. Their [docs](https://docs.rs/reqwest/0.11.4/reqwest/blocking/struct.Client.html)
explain that you should reuse a client by cloning it to take advantage of
its internal connection pool.
This was referenced Jul 7, 2021
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

Successfully merging this pull request may close these issues.

2 participants