Change8

0.46.0

Breaking Changes
📦 starletteView on GitHub →
1 breaking1 features🐛 2 fixes1 deprecations🔧 4 symbols

Summary

Starlette 0.46.0 adds a Vary header to GZipMiddleware, renames MultiPartParser’s `max_file_size` to `spool_max_size`, and deprecates `TestClient(timeout=…)`, while fixing background task exception handling and SSE compression.

⚠️ Breaking Changes

  • `MultiPartParser`: renamed parameter `max_file_size` to `spool_max_size`. Update any code that passes `max_file_size` to use `spool_max_size`.

Migration Steps

  1. Replace any usage of `MultiPartParser(max_file_size=…)` with `MultiPartParser(spool_max_size=…)`.
  2. If you rely on `TestClient(timeout=…)`, adjust your code to the recommended timeout configuration to avoid deprecation warnings.

✨ New Features

  • `GZipMiddleware` now always adds a `Vary` header when a response can be compressed.

🐛 Bug Fixes

  • Background tasks now correctly raise exceptions when used inside `BaseHTTPMiddleware`.
  • `GZipMiddleware` no longer compresses Server‑Sent Events streams.

🔧 Affected Symbols

GZipMiddlewareBaseHTTPMiddlewareMultiPartParserTestClient

⚡ Deprecations

  • `TestClient(timeout=…)` now emits a deprecation warning. Switch to the new timeout handling method if one is provided.