Opened 12 years ago

Last modified 11 years ago

#17474 closed Bug

Problem when the request doesn't have Content-Type. — at Initial Version

Reported by: Marcelo Salhab Brogliato <msbrogli@…> 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>

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top