Problem when the request doesn't have Content-Type.
|Reported by:||Marcelo Salhab Brogliato <msbrogli@…>||Owned by:||nobody|
|Cc:||olau@…, ivan_virabyan, purohit@…||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Description (last modified by aaugustin)
I don't know exactly why, but some ajax requests don't have Content-Type header.
When this happens, when I try to get request.POST, I got the following exception: 'NoneType' object has no attribute 'startswith',
raised by method _load_post_and_files at line 270 of django/http/__init__.py.
The problem is that when the request doesn't have Content-Type, self.META.get('CONTENT_TYPE', '') returns None.
To fix the problem I just did it:
content_type = self.META.get('CONTENT_TYPE', None) or '' if content_type.startswith('multipart'):
Change History (14)
comment:1 Changed 3 years ago by aaugustin
- Description modified (diff)
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:2 Changed 3 years ago by aaugustin
- Resolution set to needsinfo
- Status changed from new to closed
comment:3 follow-up: ↓ 4 Changed 2 years ago by olau
- Cc olau@… added
- Resolution needsinfo deleted
- Status changed from closed to reopened
comment:6 Changed 2 years ago by lrekucki
- Triage Stage changed from Unreviewed to Design decision needed
comment:10 Changed 21 months ago by Ashwin Purohit <purohit@…>
- Cc purohit@… added
- Version changed from 1.3 to 1.4