Hi,
On Friday, December 12, 2014 3:57:49 AM UTC-5, Artie wrote:
-- It looks like for 304 (not modified) Django specifically deletes the content-type header.
https://github.com/django/django/blob/0fc188251069b73b293f79dba6f3e9e331ad7e91/django/http/response.py#L458
It would probably be better to say:
if response.get('Content-Type', '').startswith('text/html'):
passCollin
On Friday, December 12, 2014 3:57:49 AM UTC-5, Artie wrote:
Well, I have middleware class which is required to determine content-type of rendered page and if it is 'txt/html', then do some action. I've started just from seeing what content-types do I have on page and here is first problem I faced:
class StatsMiddleware(object):
def process_view(self, request, view_func, view_args, view_kwargs):
response = view_func(request, *view_args, **view_kwargs)
print response['Content-Type']Executing this, I get few messages about content-types of page elements, like
text/html,application/javascriptand also tons of errors likekey error: content-typeand after that -broken pipeSo I assume that not all elements of page have such header
Content-Typeand my question is following:Is there some general Content-Type that says 'That page is text/html' or there are a lot of content-types on page ?
And also if this is a proper way to deterimne content-type of page like this:
if response['Content-Type'] == 'text/html': pass
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/70d3c96e-f107-4c2b-af25-af003e1af812%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment