Changes between Initial Version and Version 3 of Ticket #29276
- Timestamp:
- Mar 30, 2018, 5:34:50 AM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #29276
- Property Summary Advise to turn the headers of HTTPResponse from str to bytes automatically → Turn the headers of HTTPResponse from str to bytes automatically
-
Ticket #29276 – Description
initial v3 7 7 That is to say, the sample as below in the official document is not precisely correct. 8 8 (Page: https://docs.djangoproject.com/en/2.0/ref/request-response/) 9 {{{ 9 10 >>> response = HttpResponse(my_data, content_type='application/vnd.ms-excel') 10 11 >>> response['Content-Disposition'] = 'attachment; filename="foo.xls"' 11 12 }}} 12 13 The precise usage should be: 14 {{{ 13 15 >>> response['Content-Disposition'] = 'attachment; filename="foo.xls"'.encode('utf-8') 14 16 }}} 15 17 Otherwise, everthing will out of control If I have a Chinse character in the filename. 16 18 Wrong: 19 {{{ 17 20 >>> response['Content-Disposition'] = 'attachment; filename="中中中中中foo.xls"' 21 }}} 18 22 Correct: 23 {{{ 19 24 >>> response['Content-Disposition'] = 'attachment; filename=中中中中中foo.xls'.encode('utf-8') 20 25 }}} 21 26 Can we accept this ticket and do a minor improvement? Then we would happily only handle str in Django other than str and bytes together. 22 27 Thanks.