pypi / starlette
starlette
What changed in starlette 0.49 to 1, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
19 breaking3 security2 deprecations15 new APIs and options8 performance12 behavior and defaults3 tooling39 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initstarlette 188 changes
Breaking changes 18
Values from env files have one pair of matching outer quotes stripped.
Range is ignored for methods other than GET and HEAD, so a POST endpoint returning a file sends the full file.
FormParser.messages is gone because the parser no longer uses FormMessage.
Equality preserves the order of values under a repeated key, matching getlist(); keys can still appear in any order.
Path parameter values that look like placeholders are preserved rather than being substituted again.
Percent-encode
?,#,\and a leading//in the request path when buildingrequest.url.TestClient response bodies are streamed, so client.stream returns before the application finishes; closing an unfinished streamed response cancels the application.
By default, excludes native gRPC media types from compression.
Requires Python 3.11 or later; Python 3.10 is no longer supported.
Requires anyio>=4.0.0,<5, dropping support for AnyIO 3.
Background tasks now run only after the response is sent.
Invalid multipart parser input now returns 400.
Disconnected WebSocket operations now raise WebSocketDisconnected, a RuntimeError subclass.
FileResponse limits responses to 100 ranges.
FormParser now enforces max_fields and max_part_size limits, including in parser callbacks.
Adds an assertion error when the request parameter is not of type Request.
HTTPEndpoint now dispatches only standard HTTP verbs.
StaticFiles.lookup_path now rejects absolute paths.
Security 2
Starlette: Unvalidated request path concatenated into authority poisons request.url.hostname
Malformed Host headers are ignored when constructing request.url.
Deprecations 2
FormMessage is deprecated; calling it emits a StarletteDeprecationWarning, and the parser no longer uses it.
Use StarletteDeprecationWarning instead of DeprecationWarning for Starlette deprecation warnings.
New APIs and options 12
Adds a method to send HTTP 103 Early Hints through the ASGI http.response.early_hint extension.
Adds experimental HTTP server tracing with URL exclusions and custom tracer providers; its API and emitted telemetry may change in minor releases without a deprecation period.
Supports the QUERY HTTP method in HTTPEndpoint, CORS, and OpenAPI 3.2 schema generation.
Adds the partitioned option on Python 3.14 and later.
TestClient captures HTTP response trailers and exposes them through the response extensions mapping.
Exposes the matched route through the request scope.
Supports partitioned cookies in session middleware.
Implements identity on SimpleUser and UnauthenticatedUser.
Exposes http.response.debug info via response extensions.
Adds max_body_size to Starlette and route classes.
Adds the exclude_content_types parameter to let developers specify content types that GZipMiddleware should exclude.
The full extra now includes httpx2.
Performance 7
URL-encoded form parsing builds fields in parser callbacks instead of queueing and replaying events, reducing CPU and memory use.
Starlette clears the traceback after an exception handler runs, so reused exception instances no longer pin per-request objects in memory.
Route matching compares Match members by identity, reducing instructions per dispatch in routing benchmarks.
ServerErrorMiddleware offloads debug traceback rendering to a worker thread.
Compression resources are allocated lazily, reducing upfront resource allocation.
GZipMiddleware uses zlib.compressobj instead of GzipFile for compression.
Large GZip compression is offloaded.
Behavior and default changes 10
Host names are matched case-insensitively.
Sends http.response.start immediately for responses with an existing Content-Encoding, status 206, or an excluded content type, rather than waiting for the first body chunk.
Allows non-standard status codes without an explicit detail.
TrustedHostMiddleware and TestClient support IPv6 hosts.
Flushes GZip output for each streamed chunk.
Expands the content types excluded from compression by default.
The default for thread_minimum_size in GZipResponder changed; the notes do not specify the new value.
request.url is built from structured components.
The media type fallback is now application/octet-stream.
Starlette has reached its first stable release.
Tooling 3
TestClient typing and warnings were adjusted.
The protocol parameter is annotated with Literal.
The test client now supports httpx2, allowing developers to use it with the test client.
Fixes and other changes 34
NaN and infinity are reported correctly; NaN was previously reported as a negative float.
Comparing FormData objects with several UploadFile values under the same key no longer raises TypeError.
The parser is finalized when the request stream is exhausted, preserving the last field when a custom stream does not yield a final empty chunk.
BaseHTTPMiddleware, GZipMiddleware, and SessionMiddleware default an omitted headers field to an empty list instead of raising KeyError.
root_path is stripped only at a path segment boundary, preventing paths such as /application from becoming /lication under /app.
Use the byte length for
Content-Lengthwhen the response body is a typed or multidimensionalmemoryview.Host routing matches host names case-insensitively.
Include
HEADin theAllowheader of 405 responses whenGETis defined.Preserve every existing
Varyheader; this method is used byGZipMiddlewareandSessionMiddleware.Percent-encode
\and a leading//inurl_path_for.Stops transfers when the client disconnects.
Preserves response trailers when the middleware handles a response.
Stops a multipart range response when the file ends before a range is complete, instead of looping forever.
Ignores Range when If-Range contains a weak ETag.
Closes generators deterministically, avoiding "Exception ignored" errors with stacked BaseHTTPMiddleware.
Adds Vary: Cookie when removing an existing key.
Emits Max-Age=0 on the session cookie when max_age=0.
Includes Allow: GET, HEAD in 405 responses.
Brackets IPv6 hostnames in replacement URLs.
Normal CORS responses include Vary: Origin, and preflight responses vary by all request headers that affect them.
Configuration annotations accept Collection[str], including sets and frozensets.
Range headers are ignored when the response status is not 200, preserving its status and full body.
Malformed Host headers and IPv6 authorities are handled consistently across URL construction, host routing, and redirect middleware.
Adds support for Python 3.15.
Session mutations made with popitem() and |= are now persisted.
Handles a standalone If-None-Match: * header.
Rejects WebSocket requests without raising an assertion error.
Handles empty and absent payloads.
Inverted single-byte ranges such as bytes=5-4 are rejected.
Skips compression of partial responses.
Exception groups from user code are no longer collapsed.
Oversized suffix ranges are clamped, affecting how FileResponse handles range requests.
Closing temp files catches OSError alongside MultiPartException.
Fixes an IndexError when replacing a URL that has no authority.
starlette 0.522 changes
New APIs and options 1
State can now be accessed using dictionary-style syntax, with improved type safety.
Behavior and default changes 1
Starlette uses typing_extensions only on older Python versions.
starlette 0.512 changes
New APIs and options 1
Adds allow_private_network to CORSMiddleware.
Fixes and other changes 1
Increases the warning stacklevel for DeprecationWarning in the wsgi module.
starlette 0.501 changes
Breaking changes 1
Python 3.9 is no longer supported.
starlette 0.498 changes
Security 1
Fixes a security vulnerability in parsing the Range header in FileResponse.
New APIs and options 1
Adds an encoding parameter to the Config class.
Performance 1
Optimizes HTTP ranges parsing logic.
Behavior and default changes 1
The Middleware type is less strict, allowing a wider range of middleware typing.
Fixes and other changes 4
StaticFiles now ignores the if-modified-since header when if-none-match is present.
Avoids polluting exception context in Middleware when using BaseHTTPMiddleware.
Request.cookies supports multiple cookie headers.
Encoding values for WebSocketEndpoint use the Literal type.