Skip to content

Ensure that application/octet-stream is the default content_type#11580

Merged
Dreamsorcerer merged 18 commits intoaio-libs:masterfrom
sgaist:10889-default-content-type
Oct 14, 2025
Merged

Ensure that application/octet-stream is the default content_type#11580
Dreamsorcerer merged 18 commits intoaio-libs:masterfrom
sgaist:10889-default-content-type

Conversation

@sgaist
Copy link
Copy Markdown
Contributor

@sgaist sgaist commented Oct 6, 2025

What do these changes do?

The implementation of HeaderParser returns text/plain in case of issues as it's following mail based RFCs.

This PR makes the application/octet-stream the default in all "wrong" cases.

Are there changes in behavior for the user?

Users will get application/octet-stream in place of plain/text

Is it a substantial burden for the maintainers to support this?

The new code is based on the std library and should be of minimal impact.

Related issue number

Fixes #10889

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES/ folder
    • name it <issue_or_pr_num>.<type>.rst (e.g. 588.bugfix.rst)

    • if you don't have an issue number, change it to the pull request
      number after creating the PR

      • .bugfix: A bug fix for something the maintainers deemed an
        improper undesired behavior that got corrected to match
        pre-agreed expectations.
      • .feature: A new behavior, public APIs. That sort of stuff.
      • .deprecation: A declaration of future API removals and breaking
        changes in behavior.
      • .breaking: When something public is removed in a breaking way.
        Could be deprecated in an earlier release.
      • .doc: Notable updates to the documentation structure or build
        process.
      • .packaging: Notes for downstreams about unobvious side effects
        and tooling. Changes in the test invocation considerations and
        runtime assumptions.
      • .contrib: Stuff that affects the contributor experience. e.g.
        Running tests, building the docs, setting up the development
        environment.
      • .misc: Changes that are hard to assign to any of the above
        categories.
    • Make sure to use full sentences with correct case and punctuation,
      for example:

      Fixed issue with non-ascii contents in doctest text files
      -- by :user:`contributor-gh-handle`.

      Use the past tense or the present tense a non-imperative mood,
      referring to what's changed compared to the last released version
      of this project.

The implementation of HeaderParser returns text/plain
in case of issues as it's following mail based RFCs.

This patch makes the application/octet-stream the
default in all "wrong" cases.
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 6, 2025
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Oct 6, 2025

CodSpeed Performance Report

Merging #11580 will not alter performance

Comparing sgaist:10889-default-content-type (801396c) with master (b1bd65d)

Summary

✅ 59 untouched

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.74%. Comparing base (b1bd65d) to head (801396c).
⚠️ Report is 283 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11580      +/-   ##
==========================================
+ Coverage   98.72%   98.74%   +0.01%     
==========================================
  Files         127      127              
  Lines       43449    43467      +18     
  Branches     2326     2327       +1     
==========================================
+ Hits        42896    42922      +26     
+ Misses        395      389       -6     
+ Partials      158      156       -2     
Flag Coverage Δ
CI-GHA 98.63% <100.00%> (+0.01%) ⬆️
OS-Linux 98.36% <100.00%> (+0.01%) ⬆️
OS-Windows 96.69% <100.00%> (+0.10%) ⬆️
OS-macOS 97.58% <100.00%> (+0.12%) ⬆️
Py-3.10.11 97.14% <100.00%> (-0.01%) ⬇️
Py-3.10.18 97.64% <100.00%> (+<0.01%) ⬆️
Py-3.11.13 97.84% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 97.35% <100.00%> (+<0.01%) ⬆️
Py-3.12.10 97.45% <100.00%> (+0.27%) ⬆️
Py-3.12.11 97.95% <100.00%> (-0.01%) ⬇️
Py-3.13.7 98.21% <100.00%> (+0.68%) ⬆️
Py-3.14.0 98.15% <100.00%> (+0.25%) ⬆️
Py-3.14.0t 97.22% <100.00%> (+<0.01%) ⬆️
Py-pypy3.10.16-7.3.19 94.43% <100.00%> (?)
VM-macos 97.58% <100.00%> (+0.12%) ⬆️
VM-ubuntu 98.36% <100.00%> (+0.01%) ⬆️
VM-windows 96.69% <100.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The simplification makes sense with the way the
class is used.
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
@Dreamsorcerer Dreamsorcerer added backport-3.13 Trigger automatic backporting to the 3.13 release branch by Patchback robot backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot labels Oct 14, 2025
@Dreamsorcerer Dreamsorcerer changed the title feat: ensure that application/octet-stream is the default content_type Ensure that application/octet-stream is the default content_type Oct 14, 2025
@Dreamsorcerer Dreamsorcerer merged commit d261f8a into aio-libs:master Oct 14, 2025
41 checks passed
@patchback
Copy link
Copy Markdown
Contributor

patchback bot commented Oct 14, 2025

Backport to 3.13: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply d261f8a on top of patchback/backports/3.13/d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc/pr-11580

Backporting merged PR #11580 into master

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/aio-libs/aiohttp.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.13/d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc/pr-11580 upstream/3.13
  4. Now, cherry-pick PR Ensure that application/octet-stream is the default content_type #11580 contents into that branch:
    $ git cherry-pick -x d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc
    If it'll yell at you with something like fatal: Commit d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Ensure that application/octet-stream is the default content_type #11580 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.13/d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc/pr-11580
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@patchback
Copy link
Copy Markdown
Contributor

patchback bot commented Oct 14, 2025

Backport to 3.14: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply d261f8a on top of patchback/backports/3.14/d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc/pr-11580

Backporting merged PR #11580 into master

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/aio-libs/aiohttp.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.14/d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc/pr-11580 upstream/3.14
  4. Now, cherry-pick PR Ensure that application/octet-stream is the default content_type #11580 contents into that branch:
    $ git cherry-pick -x d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc
    If it'll yell at you with something like fatal: Commit d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Ensure that application/octet-stream is the default content_type #11580 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.14/d261f8a3ceaeb9699c13d6f62be9ea875f6f40bc/pr-11580
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

@Dreamsorcerer
Copy link
Copy Markdown
Member

Thanks for that fix. If you could create the backports with the above instructions, that'd be great, otherwise I'll look at them later in the week.

sgaist added a commit to sgaist/aio-libs-aiohttp that referenced this pull request Oct 15, 2025
@sgaist sgaist deleted the 10889-default-content-type branch October 15, 2025 07:33
@sgaist
Copy link
Copy Markdown
Contributor Author

sgaist commented Oct 15, 2025

You're welcome !

Backport PR created :-)

Dreamsorcerer pushed a commit that referenced this pull request Oct 15, 2025
…am is the default content_type (#11655)

(cherry picked from commit d261f8a)
patchback bot pushed a commit that referenced this pull request Oct 15, 2025
…am is the default content_type (#11655)

(cherry picked from commit d261f8a)
(cherry picked from commit 1e24afc)
Dreamsorcerer pushed a commit that referenced this pull request Oct 15, 2025
…] Ensure that application/octet-stream is the default content_type (#11660)

**This is a backport of PR #11655 as merged into 3.14
(1e24afc).**

(cherry picked from commit d261f8a)

Co-authored-by: Samuel Gaist <[email protected]>
commonism added a commit to commonism/acmetk that referenced this pull request Oct 25, 2025
commonism added a commit to commonism/acmetk that referenced this pull request Oct 25, 2025
commonism added a commit to noahkw/acmetk that referenced this pull request Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-3.13 Trigger automatic backporting to the 3.13 release branch by Patchback robot backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default Content-Type with malformed header

3 participants