Commit 732696e8 authored by Patryk's avatar Patryk Committed by Tim Neutkens

Add a charset to the default Content-Type (#3333)

parent e2bcb039
......@@ -186,7 +186,7 @@ export function sendHTML (req, res, html, method, { dev }) {
res.setHeader('ETag', etag)
if (!res.getHeader('Content-Type')) {
res.setHeader('Content-Type', 'text/html')
res.setHeader('Content-Type', 'text/html; charset=utf-8')
}
res.setHeader('Content-Length', Buffer.byteLength(html))
res.end(method === 'HEAD' ? null : html)
......
......@@ -2,7 +2,7 @@ import React from 'react'
export default class extends React.Component {
static async getInitialProps ({res}) {
if (res) {
res.setHeader('Content-Type', 'text/html; charset=utf-8')
res.setHeader('Content-Type', 'text/html; charset=iso-8859-2')
}
return {}
}
......
......@@ -71,12 +71,12 @@ export default function ({ app }, suiteName, render, fetch) {
test('default Content-Type', async () => {
const res = await fetch('/stateless')
expect(res.headers.get('Content-Type')).toMatch('text/html')
expect(res.headers.get('Content-Type')).toMatch('text/html; charset=utf-8')
})
test('setting Content-Type in getInitialProps', async () => {
const res = await fetch('/custom-encoding')
expect(res.headers.get('Content-Type')).toMatch('text/html; charset=utf-8')
expect(res.headers.get('Content-Type')).toMatch('text/html; charset=iso-8859-2')
})
test('allows to import .json files', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment