Opened 14 years ago
Last modified 13 years ago
#17474 closed Bug
Problem when the request doesn't have Content-Type. — at Version 1
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | HTTP handling | Version: | 1.4 |
| Severity: | Normal | Keywords: | content-type |
| Cc: | olau@…, Ivan Virabyan, purohit@… | Triage Stage: | Design decision needed |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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'):
Note:
See TracTickets
for help on using tickets.
Improved formatting (please use preview).