Skip to content

Firefox Character Encoding #100

@9mido

Description

@9mido

Firefox console shows this error:

"The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature."

Current code:

url(r'^robots.txt/', include('robots.urls')),


Alternatives?

path('robots.txt', TemplateView.as_view(template_name="robots.txt", content_type='text/plain')),
url(r'^robots.txt', lambda x: HttpResponse("User-Agent: *\nDisallow:", content_type="text/plain"), name="robots_file"),


How do you combine include('robots.urls') with the alternatives or is it not possible?

It should probably be:

content="text/html; charset=utf-8" or "text/plain; charset=UTF8" not 'text/plain'​​

curl -s -D - 127.0.0.1:8000/robots.txt/
HTTP/1.1 200 OK
Date: Tue, 14 Apr 2020 01:05:52 GMT
Server: WSGIServer/0.2 CPython/3.7.3
Content-Type: text/plain

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions