Opened 13 years ago
Last modified 12 years ago
#17474 closed Bug
Problem when the request doesn't have Content-Type. — at Initial Version
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
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 (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:
<code>
content_type = self.META.get('CONTENT_TYPE', None) or
if content_type.startswith('multipart'):
</code>