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

Replace reqwest with ureq #49

Merged
merged 1 commit into from
Dec 13, 2020
Merged

Conversation

agersant
Copy link
Contributor

@agersant agersant commented Dec 9, 2020

This took significantly less effort than I expected 🥳

Addresses #47

@@ -194,7 +190,16 @@ impl LastFm {
params.insert("method".to_string(), operation.to_string());
params.insert("api_sig".to_string(), signature);

self.http_client.post(url).form(&params).send()
let params: Vec<(&str, &str)> = params
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I though the HashMap<String, String> is more convenient to manipulate headers while crafting a request, so we only do this conversion at the last minute.

.collect();

let resp = self.http_client.post(url).send_form(&params[..]);
match resp.synthetic_error() {
Copy link
Contributor Author

@agersant agersant Dec 9, 2020

Choose a reason for hiding this comment

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

ureq always returns a response object, even when there is a transfer error (docs). This small check uncovers transfer errors masquerading as HTTP responses.

Copy link
Owner

@dmfutcher dmfutcher left a comment

Choose a reason for hiding this comment

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

Nice work, thanks very much for contributing again!

More than halves the dependency count 👍

$ cargo tree | wc -l
365

vs

$ cargo tree | wc -l
134

Will let you know when release is out.

@dmfutcher dmfutcher merged commit 3e7933b into dmfutcher:master Dec 13, 2020
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