#28786 closed Cleanup/optimization (fixed)
Document middleware ordering considerations due to CommonMiddleware setting Content-Length
Reported by: | spudnica | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 1.11 |
Severity: | Normal | Keywords: | content-length, commonMiddleware, development-server |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Hi!
After updating to Django 1.11 I cant display pages in Chrome, due to error printed in Chrome console: net::ERR_CONTENT_LENGTH_MISMATCH
The above error does not occur in Mozilla or IE. When I delete lines responsible for Content-Length header from CommonMiddleware error disappears and my site works just fine.
Its not just mine Chrome, I tested issue on few PCs.
Change History (9)
comment:1 by , 7 years ago
Description: | modified (diff) |
---|
follow-up: 3 comment:2 by , 7 years ago
comment:3 by , 7 years ago
Description: | modified (diff) |
---|
Replying to Tim Graham:
I think we'll need more details about how to reproduce the problem.
- I guess the issue is related to way that content-length is calculated. If I manually set content-length to match particular page I request for, I am able to open this in Chrome. It seems that str(len(response.content)) is not returning proper reponse length i CommonMiddleware for me and firefox was just ignoring it.
- If I order CommonMiddleware at first place in my middlewares list, site is working properly, though it is against reccommendations in Django docs guide Middleware ordering.
comment:5 by , 7 years ago
Error is related to middleware order. If the content is modified after calculation of length (and in my case it was) comparison between values always returns False. I guess it affects everyone with apps like django-livereload or similar apps, which injects content into site. Is this header necessary to exist because of security or some different point?
Its worth to add info about order of middlewares to release notes of version 1.11, to prevent people from digging through internet.
comment:6 by , 7 years ago
Component: | Core (Other) → Documentation |
---|---|
Has patch: | set |
Summary: | Content-Length mismatch on Chrome → Document middleware ordering considerations due to CommonMiddleware setting Content-Length |
Type: | Uncategorized → Cleanup/optimization |
PR to mention that consideration in the release notes.
I think we'll need more details about how to reproduce the problem.