Skip to content

cargo publish does not send Content-Type header #16830

@dralley

Description

@dralley

Problem

Context: I am writing a new 3rd party registry implementation (https://github.com/pulp/pulp_rust)

I noticed that cargo publish does not send the Content-Type header. Per RFC 7231, senders SHOULD include Content-Type when a body is present. The omission causes problems with web frameworks like Django REST Framework (which I am using) that select a body parser based on Content-Type and fall back to a JSON parser when the header is absent, which of course doesn't work because the body is actually a binary payload.

Steps

  1. Send a cargo publish request against an MITM or alternate registry implementation which logs incoming request metadata
  2. Observe that the request carries no Content-Type header

Possible Solution(s)

Add headers.append("Content-Type: application/octet-stream")?; to here

Notes

No response

Version

cargo 1.94.0 (85eff7c80 2026-01-15)
release: 1.94.0
commit-hash: 85eff7c80277b57f78b11e28d14154ab12fcf643
commit-date: 2026-01-15
host: x86_64-unknown-linux-gnu
libgit2: 1.9.2 (sys:0.20.3 vendored)
libcurl: 8.17.0-DEV (sys:0.4.84+curl-8.17.0 vendored ssl:OpenSSL/3.5.4)
ssl: OpenSSL 3.5.4 30 Sep 2025
os: Fedora 43.0.0 [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-documenting-cargo-itselfArea: Cargo's documentationA-interacts-with-crates.ioArea: interaction with registriesC-bugCategory: bugCommand-publishS-acceptedStatus: Issue or feature is accepted, and has a team member available to help mentor or review

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions