Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions airflow-core/src/airflow/api_fastapi/core_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,9 @@ def init_config(app: FastAPI) -> None:
# Compress responses greater than 1kB with optimal compression level as 5
# with level ranging from 1 to 9 with 1 (fastest, least compression)
# and 9 (slowest, most compression)
app.add_middleware(GZipMiddleware, minimum_size=1024, compresslevel=5)

app.state.secret_key = get_signing_key("api", "secret_key")


def init_error_handlers(app: FastAPI) -> None:
from airflow.api_fastapi.common.exceptions import ERROR_HANDLERS

Expand All @@ -185,3 +183,5 @@ def init_middlewares(app: FastAPI) -> None:
from airflow.api_fastapi.auth.managers.simple.middleware import SimpleAllAdminMiddleware

app.add_middleware(SimpleAllAdminMiddleware)

app.add_middleware(GZipMiddleware, minimum_size=1024, compresslevel=5)
11 changes: 11 additions & 0 deletions airflow-core/tests/api_fastapi/test_middleware_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest


@pytest.mark.integration
def test_health_endpoint_not_chunked(test_client):
response = test_client.get("/api/v2/monitor/health")

# Ensure we do not reintroduce Transfer-Encoding: chunked
assert "transfer-encoding" not in {
k.lower(): v for k, v in response.headers.items()
}