Skip to content

Send Content-Type header with cargo publish requests#16832

Merged
weihanglo merged 3 commits intorust-lang:masterfrom
dralley:fixes
Apr 5, 2026
Merged

Send Content-Type header with cargo publish requests#16832
weihanglo merged 3 commits intorust-lang:masterfrom
dralley:fixes

Conversation

@dralley
Copy link
Copy Markdown
Contributor

@dralley dralley commented Apr 3, 2026

What does this PR try to resolve?

Sends an appropriate Content-Type header with cargo publish requests.

Resolves:

#16830

How to test and review this PR?

If necessary, find a way to log the request headers / metadata - I tested this against my in-progress registry implementation. Maybe there is logging mode which can skip that step, I'm not sure.

@rustbot rustbot added A-interacts-with-crates.io Area: interaction with registries S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 3, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 3, 2026

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

@dralley dralley changed the title Fixes two issues that make writing Fixes two issues that help third party registries Apr 3, 2026
@dralley dralley changed the title Fixes two issues that help third party registries Fixes two issues that unnecessarily complicate third party registry implementations Apr 3, 2026
@epage
Copy link
Copy Markdown
Contributor

epage commented Apr 3, 2026

Note that our contrib guide asks for Issues to be tagged S-accepted before moving onto PRs.

In addition, this would best be handled with separate PRs because

  • They are unrelated
  • They have different compatibility considerations and on or more might need team sign off with an FCP

@dralley
Copy link
Copy Markdown
Contributor Author

dralley commented Apr 3, 2026

Ok, I can split into two PRs. Apologies.

And I will wait before filing a PR for the other issue.

@dralley dralley changed the title Fixes two issues that unnecessarily complicate third party registry implementations Send Content-Type header with cargo publish requests Apr 3, 2026
@rustbot

This comment has been minimized.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 3, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

Comment thread crates/crates-io/lib.rs
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#16830 (comment)

Would you mind also updating docs?

I guess we can instead specify content-type in each API respectively

dralley added 3 commits April 4, 2026 11:13
Revise how the header documentation is written such that per-endpoint
headers are more straightforwards.
Take the body argument as Option<&[u8]
@rustbot rustbot added the A-documenting-cargo-itself Area: Cargo's documentation label Apr 4, 2026
@dralley
Copy link
Copy Markdown
Contributor Author

dralley commented Apr 4, 2026

@weihanglo The last commit is a separate (but related) issue re: the unyank command, I imagine you might want that split off as a separate PR?

Comment thread crates/crates-io/lib.rs
}

fn put(&mut self, path: &str, b: &[u8]) -> Result<String> {
fn put(&mut self, path: &str, b: Option<&[u8]>) -> Result<String> {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is how all of the other methods were written, this was otherwise an outlier.

Comment thread crates/crates-io/lib.rs

pub fn unyank(&mut self, krate: &str, version: &str) -> Result<()> {
let body = self.put(&format!("/crates/{}/{}/unyank", krate, version), &[])?;
let body = self.put(&format!("/crates/{}/{}/unyank", krate, version), None)?;
Copy link
Copy Markdown
Contributor Author

@dralley dralley Apr 4, 2026

Choose a reason for hiding this comment

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

This was setting Content-Type: application/json for a body which was empty (which is not actually valid json)

Copy link
Copy Markdown
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Thanks for it and also the discussion!

View changes since this review

@weihanglo weihanglo added this pull request to the merge queue Apr 5, 2026
Merged via the queue into rust-lang:master with commit bc00373 Apr 5, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 5, 2026
@dralley dralley deleted the fixes branch April 5, 2026 15:34
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Apr 8, 2026
Cargo submodule update

11 commits in a357df4c26fc14514e66aae2a269456b5545c7db..101549dddbd2b08e806f50154e3aa4cb3374cc21
2026-04-03 16:47:15 +0000 to 2026-04-08 12:51:20 +0000
- Never include use extra-filename in build scripts (rust-lang/cargo#16855)
- fix(toml): Force script edition warnings on quiet  (rust-lang/cargo#16848)
- GitHub fast path uses `http_async` (rust-lang/cargo#16847)
- feat(manifest): allow git dependency alongside alternate registry (rust-lang/cargo#16810)
- fix(auth): add auth scheme hint to token rejected error for alt registries (rust-lang/cargo#16794)
- Warn on invalid jobserver file descriptors (rust-lang/cargo#16843)
- docs(unstable): List the minimum required MSRV for 'public' field (rust-lang/cargo#16841)
- feat(lints): Emit unused_dependencies lint (rust-lang/cargo#16600)
- fix(tree): clarify error message when `-i` is used without a package name (rust-lang/cargo#16818)
- fix: Typo in target.&lt;cfg&gt;.linker (rust-lang/cargo#16839)
- Send Content-Type header with cargo publish requests (rust-lang/cargo#16832)

r? ghost
@rustbot rustbot added this to the 1.96.0 milestone Apr 8, 2026
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Apr 13, 2026
Cargo submodule update

11 commits in a357df4c26fc14514e66aae2a269456b5545c7db..101549dddbd2b08e806f50154e3aa4cb3374cc21
2026-04-03 16:47:15 +0000 to 2026-04-08 12:51:20 +0000
- Never include use extra-filename in build scripts (rust-lang/cargo#16855)
- fix(toml): Force script edition warnings on quiet  (rust-lang/cargo#16848)
- GitHub fast path uses `http_async` (rust-lang/cargo#16847)
- feat(manifest): allow git dependency alongside alternate registry (rust-lang/cargo#16810)
- fix(auth): add auth scheme hint to token rejected error for alt registries (rust-lang/cargo#16794)
- Warn on invalid jobserver file descriptors (rust-lang/cargo#16843)
- docs(unstable): List the minimum required MSRV for 'public' field (rust-lang/cargo#16841)
- feat(lints): Emit unused_dependencies lint (rust-lang/cargo#16600)
- fix(tree): clarify error message when `-i` is used without a package name (rust-lang/cargo#16818)
- fix: Typo in target.&lt;cfg&gt;.linker (rust-lang/cargo#16839)
- Send Content-Type header with cargo publish requests (rust-lang/cargo#16832)

r? ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-documenting-cargo-itself Area: Cargo's documentation A-interacts-with-crates.io Area: interaction with registries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants