Opened 13 years ago

Last modified 12 years ago

#17474 closed Bug

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

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 (last modified by Aymeric Augustin)

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 (1)

comment:1 by Aymeric Augustin, 13 years ago

Description: modified (diff)

Improved formatting (please use preview).

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