-
-
Notifications
You must be signed in to change notification settings - Fork 962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gzip Middleware content-length is incorrect #803
Comments
I've taken a quick look over the
All of that looks correct to me. (Although I'm certainly prepared to believe that there could be an issue here, it's just that it's not obvious at first sight?) Can you narrow this down to a simple reproducible case? |
Thank you for your reply. But I'm in China, it's already late at night. Tomorrow i will give you a minimal implementation. |
from starlette.applications import Starlette
from starlette.middleware.gzip import GZipMiddleware
from starlette.middleware.wsgi import WSGIMiddleware
from starlette.routing import Route
from wsgi_example.wsgi import application
routes = [
Route("/", endpoint=WSGIMiddleware(application)),
]
app = Starlette(routes=routes)
app.add_middleware(GZipMiddleware)
running
The three library versions involved are Django: 3.0.2, starlette: 0.13.0, uvicorn: 0.11.1. |
Okay, it'll almost certainly be an issue with attempting to apply GZip compression to a response that's already GZipped compressed. You probably have a Gzip middleware installed in the Django settings, as well as on the containing Starlette application. If you remove the GZip middleware from one of those two places then the issue should resolve. (Although we should still fix this case in Starlette.) |
I checked and found that Django does not have the default Gzip behavior, and I haven't found anything about Gzip in Middleware. I don't quite understand what you mean, I only used Gzip once in starlette. MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
] |
Thanks for raising this. Turns out the WSGI middleware was not lowercasing the ASGI headers, as mandated by the ASGI spec, and as a result a |
The following exception is thrown when I use uvicorn to drive my starlette project. After control variates, I am sure this is caused by Gzip Middleware.
The text was updated successfully, but these errors were encountered: