Opened 19 years ago

Closed 19 years ago

Last modified 12 years ago

#72 closed defect (fixed)

Django should add charset info to output HTTP headers

Reported by: anonymous Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

It seems Django doesn't add the "charset=utf8" field to "Content-type: text/html" header while sending headers to the browser. This cause pages encoded as UTF-8 look wrong in the browser (Firefox assumes page is encoded using iso-8859-1, which is the default HTTP encoding).

Sample headers sent by Django:

Date: Mon, 18 Jul 2005 20:51:43 GMT
Server: Apache/2.0.54 (Win32) mod_python/3.1.4 Python/2.4.1
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

200 OK

Patching Content-type header to look like "Content-Type: text/html; charset=utf-8" would make clear which encoding is used by the server.

More info about charset param here.

Change History (5)

comment:1 by Adrian Holovaty, 19 years ago

You're suggesting that it send out the charset just for admin pages, right? Not for every page by default?

comment:2 by deelan, 19 years ago

All those pages "generated" by Django, or better, all those pages where Django has a change to set response headers.

comment:3 by Adrian Holovaty, 19 years ago

Resolution: fixed
Status: newclosed

Fixed in [340].

comment:4 by Martin, 17 years ago

Ok, what happens if I want a different encoding, other then utf8 ?
Is there a way to change the default behaviour ?

comment:5 by anonymous, 12 years ago

Easy pickings: unset
UI/UX: unset
response['Content-Disposition'] = 'attachment; filename=%s'% file_name.encode('utf-8')
Note: See TracTickets for help on using tickets.
Back to Top