Send Content-Type header with cargo publish requests#16832
Send Content-Type header with cargo publish requests#16832weihanglo merged 3 commits intorust-lang:masterfrom
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Note that our contrib guide asks for Issues to be tagged In addition, this would best be handled with separate PRs because
|
|
Ok, I can split into two PRs. Apologies. And I will wait before filing a PR for the other issue. |
This comment has been minimized.
This comment has been minimized.
|
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. |
There was a problem hiding this comment.
Would you mind also updating docs?
I guess we can instead specify content-type in each API respectively
Revise how the header documentation is written such that per-endpoint headers are more straightforwards.
Take the body argument as Option<&[u8]
|
@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? |
| } | ||
|
|
||
| fn put(&mut self, path: &str, b: &[u8]) -> Result<String> { | ||
| fn put(&mut self, path: &str, b: Option<&[u8]>) -> Result<String> { |
There was a problem hiding this comment.
This is how all of the other methods were written, this was otherwise an outlier.
|
|
||
| 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)?; |
There was a problem hiding this comment.
This was setting Content-Type: application/json for a body which was empty (which is not actually valid json)
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.<cfg>.linker (rust-lang/cargo#16839) - Send Content-Type header with cargo publish requests (rust-lang/cargo#16832) r? ghost
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.<cfg>.linker (rust-lang/cargo#16839) - Send Content-Type header with cargo publish requests (rust-lang/cargo#16832) r? ghost
What does this PR try to resolve?
Sends an appropriate
Content-Typeheader withcargo publishrequests.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.