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

Add required user-agent to crates-io lib api (breaking change) #6969

Closed

Conversation

FGRibreau
Copy link

Since cargo.io now requires a User-Agent header (see message below), I've updated the crates-io crate accordingly. Hope this will be approved and generate a new release of crates-io :)

This is a breaking change because there is an contract change on (added user_agent: Option<String>):

  • Registry::new(host: String, token: Option<String>, user_agent: Option<String>)
  • Registry::new_handle(host: String, token: Option<String>, user_agent: Option<String>, handle: Easy)

Message from crates.io:

We require that all requests include a `User-Agent` header. 
To allow us to determine the impact your bot has on our service, we ask that your user agent actually identify your bot, and not just report the HTTP client library you're using.  
Including contact information will also reduce the chance that we will need to take action against your bot.

Bad:
User-Agent: reqwest/0.9.1

Better:
User-Agent: my_crawler

Best:
User-Agent: my_crawler (my_crawler.com/info)
User-Agent: my_crawler (help@my_crawler.com)

If you believe you've received this message in error, please email help@crates.io and include the request id 7da610ae-264a-4738-a979-c53465fa8c99.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 20, 2019
@FGRibreau FGRibreau changed the title BREAKING CHANGE: Add required user-agent to crates-io lib api (breaking change) May 20, 2019
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

Thanks, I ran into this with another project.

src/cargo/ops/registry.rs will need to be updated to no longer add the user-agent manually.

Also, I'm thinking it might be better to not use an Option, and require an explicit value.

src/crates-io/lib.rs Outdated Show resolved Hide resolved
@FGRibreau
Copy link
Author

Also, I'm thinking it might be better to not use an Option, and require an explicit value.

@ehuss you're right indeed, I removed the Option :)

@ehuss
Copy link
Contributor

ehuss commented May 21, 2019

Can you also update src/cargo/ops/registry.rs as mentioned above?

@ehuss
Copy link
Contributor

ehuss commented May 21, 2019

Hm, I think I wasn't clear. There is custom handling for the user agent in configure_http_handle. That will need to be handled, and somehow shared. Unfortunately this stuff is used all over, so it may not be so simple to update. Perhaps it would be best just to update Registry::new and leave Registry::new_handle unchanged? Cargo doesn't use Registry::new, and maybe a doc comment could be added to new_handle informing the user they must set the user-agent header.

@ehuss ehuss added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 5, 2019
@bors
Copy link
Collaborator

bors commented Jun 18, 2019

☔ The latest upstream changes (presumably #7011) made this pull request unmergeable. Please resolve the merge conflicts.

@alexcrichton
Copy link
Member

This has gone stale for some time now so I'm going to close this, but feel free to resubmit of course!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants