fastapi: emit a single Server header and stop gzip-inflating tiny bodies - #1054
Merged
Kaliumhexacyanoferrat merged 2 commits intoJul 26, 2026
Merged
Conversation
- Replace the BaseHTTPMiddleware-based ServerHeaderMiddleware with uvicorn's --no-server-header --header Server:FastAPI: responses previously carried both 'server: uvicorn' and 'server: FastAPI', now exactly one 'server: FastAPI' at zero per-request cost - Raise GZipMiddleware minimum_size from 1 to 1000 (the value in FastAPI's own docs example; compresslevel=5 unchanged) so tiny bodies are no longer inflated by compression Fixes MDA2AV#1052 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
|
/benchmark -f fastapi --save |
Contributor
|
👋 |
Contributor
Benchmark ResultsFramework:
Full log |
Collaborator
|
Okay, wow 😄 |
Kaliumhexacyanoferrat
approved these changes
Jul 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1052.
BaseHTTPMiddleware-basedServerHeaderMiddlewareand pass--no-server-header --header Server:FastAPIto uvicorn instead. Responses previously carried bothserver: uvicornandserver: FastAPI; they now carry exactly oneserver: FastAPI, at zero per-request cost.minimum_size=1→1000— the value in FastAPI's own GZipMiddleware docs example;compresslevel=5unchanged. Happy to switch to Starlette's default (500) if you prefer.Verified by building the entry's Dockerfile (uvicorn 0.40.0) and probing the container:
/baseline11?a=13&b=42→200, singleserver: FastAPI, and noContent-Encodingeven withAccept-Encoding: gzip(the 2-byte body is no longer inflated)/json/50?m=1withAccept-Encoding: gzip, br→Content-Encoding: gzip(7602 B → 423 B); noContent-Encodingwithout Accept-Encoding — the json-comp validation checks still pass🤖 Generated with Claude Code